You are making an iPod playlist to hear the songs. Assuming that shuffle functions are not applicable, choose an appropriate data structure that will add and delete songs onto you’re your iPod in such a way that the recently inserted song will always be the first song currently on the iPod.
Answers
Answered by
1
===============================
Answer By shreyas
Attachments:
Answered by
0
The stack data structure is the best approach that will add and delete songs onto you’re your iPod in such a way that the recently inserted song will always be the first song currently on the iPod.
- A linear data structure with either FILO (First In Last Out) or LIFO (Last In First Out) order represents the stack.
- These two orders are followed and the operations are performed by using a stack data structure.
- So if any song is added to the iPod recently, then it will become the last song.
- But the stack data structure will collect the latest song information and the song will come out as the first.
- This is just like placing toy blocks one after another to make a tower. The last block will be the first and topmost.
- Different operations like push(), pop(), top(), isEmpty(), size(), etc. can be used within a stack data structure to navigate the data within it.
- push() makes a new element gets added to a stack and pop() removes it.
- So, the best approach, in this case, is the stack data structure.
#SPJ2
Similar questions