• Home
  • University of the People
  • Data Structures (proctored course) CS 3303
  • Understanding Lists, Stacks, and Queues in Data Structures

Understanding Lists, Stacks, and Queues in Data Structures

This week's assignments were interesting not only because of the programming assignment but also because the reading assignment shed light on some of the concepts which I had just blindly used over the years as a computer science student. The unit provided information about lists (Specifically array based lists and linked lists, stacks and queues). What I am also appreciating about this course is its emphasis on cost of the code in terms of space and time when the program is being implemented. I think this is a very important concept which results in overall system efficiency, given the fact that computer systems almost always have hardware limitations. The written assignment was challenging and interesting at the same time. Whilst most of the code guidelines were already in the textbook, it really took me more than the expected time to implement the algorithm. I also feel that there are a lot of improvements which I could have made to my code, had I managed to finish within a reasonable amount of time. For instance, my final code had no comments. I know that this is bad programming practice and this is something I will definitely need to improve on next time. Furthermore, I could have simply used a for loop to push values into the stack, but I repeated lines of code which could otherwise have been made efficient by the loop. This is also something I will need to improve in future. I also had an issue with Jeliot. I noted that just because my code worked well in eclipse does not mean it will pass in Jeliot. I had used the Integer wrapper class in my interface definitions for the length of the list but I used the int primitive type in the main method. I only managed to note this in Jeliot as it refused to complete the simulations. I really appreciate the in-depth and yet simple explanations given in the book about the stack and the queue data structure. In simple terms, a stack uses a Last In First Out (LIFO) policy where only one end is used for both inserting elements to, and removing elements from the list. A queue uses a First In First Out (FIFO) policy where one end is used to insert elements whilst the other is used to remove elements. I also understood that arrays have a higher time complexities than linked lists because inserting elements into the array requires shifting all the other elements down. Furthermore, if the array size is not known, the data structure may reserve memory which will never be used by the program. Whilst there are several ways to resize the array (such as using the system.arraycopy()), I feel these also add extra overhead to the program. The linked lists have considerably lower time complexities although there is an issue of space, since there can be as many as two pointers from one node to the other, which increases space complexity. Finally, I realise that the