-
Notifications
You must be signed in to change notification settings - Fork 9
/
SortingAndSearchingPractise
33 lines (17 loc) · 1.43 KB
/
SortingAndSearchingPractise
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Sorting Questions
1.1. How would you sort an array of strings alphabetically in JavaScript?
1.2. How would you sort an array of numbers in ascending order? In descending order?
1.3. Explain the time complexity and space complexity of QuickSort, MergeSort, and BubbleSort.
1.4. Given an array of objects, how would you sort the array based on a specific object key?
1.5. Could you explain the difference between sort() and localeCompare() for sorting strings in JavaScript?
1.6. How would you implement a stable sort in JavaScript? (JavaScript's native sort() is not stable)
1.7. How would you sort an array so that all zeros are moved to the end, without changing the order of the other elements?
Searching Questions
2.1. How would you find the index of a particular item in an array in JavaScript?
2.2. How would you check if a particular value exists in an array or not?
2.3. Could you explain the difference between indexOf() and findIndex() methods in JavaScript?
2.4. Explain the concept of Binary Search. What are its time and space complexities?
2.5. How would you find the first non-repeating character in a string using JavaScript?
2.6. Describe how you would implement a depth-first search on a tree data structure in JavaScript.
2.7. Explain how to use filter() and find() methods in JavaScript to search for elements in an array.
2.8. How would you implement a function to perform a case-insensitive search for a substring within a string?