Tutor profile: Lok C.
Why does JS support both == and === instead of just updating == to the current definition of ===?
JS is made as a language for web development and was made relatively quickly. As such there are some bugs that exist in it to this day. One of those is the intransitive nature of ==. However, due to the fact that JS is a web development language, it is important that any changes made to it doesn't break the existing web. Hence the reason why === was introduced instead of updating ==.
Subject: Discrete Math
There are 20 students in a school. This school requires all students to join one club. There are a total of 3 clubs, A, B, and C. Clubs can have between 0 to 20 students in them. Students are only allowed in one club. Assuming the students are indistinguishable, how many different ways are there for the students to be arranged in the clubs. With indistinguishable meaning that if student 1 from club A and student 2 from club B swap places, it would still only count as one arrangement.
The problem is asking for the number of combination of students in clubs. This can be seen as a sum problem. If the number of members in each club can be represented by A,B,and C respectively, then the number of different valid solutions for A + B + C = 20 would give the solution to the problem. One obvious way to solve this is through brute force enumeration. That solution will be omitted as there is another method. Take a smaller problem of 5 students and 2 clubs, the students are represented by O, and the division of clubs be represented by |. So OOOOO| means there are 5 students in club A and |OOOOO means there are 5 students in club B. By choosing the position of the divider we are able to find different arrangement of students in clubs. Thus we can solve this problem by taking the number of students + (number of clubs - 1) and choosing (number of clubs - 1) places. or (N + K -1) C (K-1). Resulting in the answer of 22 C 2 or 231 arrangements.
Subject: Computer Science (General)
Explain why it is important to learn about different data structures when everything can be implemented with arrays.
Although different data structures are all just ways to contain data, the way they contain data differently is very important. One can think of different data structures as different types of containers with their own purposes. For example, one shouldn't try to carry water with a woven basket nor try to carry boiling water in a metal cup. In the same way, different data structures specialize in different tasks. Maps are good when one wants 1-1 correspondence between two items, trees are good when a problem can be subdivided, and linked lists are good when one doesn't want to reserve blocks of data ahead of time. To sum it up, it is important to learn about different data structures because it is important to know what tools you have in your toolbox. It is only then when one is capable of solving any problem in front of them.
needs and Lok will reply soon.