PokeVideoPlayer v23.9-app.js-020924_
0143ab93_videojs8_1563605_YT_2d24ba15 licensed under gpl3-or-later
Views : 631,510
Genre: Science & Technology
License: Standard YouTube License
Uploaded At Aug 14, 2024 ^^
warning: returnyoutubedislikes may not be accurate, this is just an estiment ehe :3
Rating : 4.952 (531/43,880 LTDR)
98.80% of the users lieked the video!!
1.20% of the users dislieked the video!!
User score: 98.20- Masterpiece Video
RYD date created : 2024-11-22T03:31:28.523954Z
See in json
Top Comments of this video!! :3
Big O is useful if you are being academic or generic, but in many real world cases you can get significantly better performance if you understand your data.
For example, if you have a deck of cards that isn't sorted, you can easily sort it in linear time by doing the following:
1. Allocate your sorted array with 52 elements
2. Loop over the unsorted deck and calculate an index based on the suit and number (13*suit ID + number - 1) and put the card in that spot in the result sorted array
Always look at the data and problem you have and solve for that. If your problem is sorting decks of cards then solve that problem and don't use a generic method like quick sort or merge sort.
4 |
You could use the fact that a deck of cards only has a few ranks of them. You'd only need to loop the deck once. Give a number to each one. Then have a hashmap, translating card names to these indexes you have. And use an array of integers, where the index tells you, how many of that card are in the stack. As you loop through the stack, looking at the cards, for each one, you lookup it in the array (using the index it has), in O(1), and incrementing its count. After you're done, you simply walk the array of counts once, and output the rank of each card as many times as the number tells you. Boom, sorted stack, linear time
3 |
@dale3478
3 months ago
In 1 universe out of the countless possible universes in multiverse, bogosort can perfectly sort data in O(1) time
3.7K |