Quick actions

cmd+k|ctrl+k

Navigation

Languages

Interview Sorting Qs

Snippet info

Language

JavaScript

Visibility

public

Author

vinnysantos559

Created

2020-01-08T02:02:21Z

Updated

2020-01-08T03:31:21Z

//#1 - Sort 10 schools around your house by distance:
//Selection Sort: for a list of 10 items time or space complexity are out of concern and readable, easy to implement code is more important.

//#2 - eBay sorts listings by the current Bid amount:
//Quick Sort: depeneding on the item ID, the amount of listings could vary from few to very many, so might as well be ready for worst case scenario.

//#3 - Sport scores on ESPN
//Selction Sort: same answer as #1

//#4 - Massive database (can't fit all into memory) needs to sort through past year's user data
//Quick Sort: Is faster on average than most other algos and is less memory intensive than merge sort.

//#5 - Almost sorted Udemy review data needs to update and add 2 new reviews
//Insertion Sort: Can be a O(n) time complexity for nearly sorted data and is less complex than merge or quick sort.

//#6 - Temperature Records for the past 50 years in Canada
//Merge Sort: I'd pick this over quick sort because the temperatures may correspond to some city and this might reflect in the input order. 
//Merge sort is a stable algorithm and can keep the data's integrity.

//#7 - Large user name database needs to be sorted. Data is very random.
//Quick Sort: Stable algorithm is not needed if you need to sort the data twice by last name then first. 

//#8 - You want to teach sorting for the first time
//Bubble Sort or Selection Sort: both very easy to grasp coneceptually and not difficult to implement.
INFO