- Type
- Midterm past paper
- Course
- CS301 Data Structures
- Size
- PDF 325 KB
- Updated
- 23 Oct 2026
You get 3 free files a day on the website. Add the Chrome extension for 30 a day.
Preview text
Text from pages 1, 2, 3 of 6. Download the file for all 6 pages.
CS301- Short Notes for Midterm Exams 2021
Linked List
- LInked List Low-level data structure
- Represent a sequence of nodes that have pointers to other nodes.
- 3 basic kinds of linked list Singly Linked List
Circular Linked List
- Head No matter how many nodes are present in the linked list, the very first node is called head
- Tail The last node is called the tail. If there is just one node created then it is called both head and tail.
- Singly Linked List In this list, the nodes each have one pointer to the next node
- doubly-linked list In a doubly-linked list contains some data, a link to the next node and a link to the previous node.
Q7. A node in Singly Linked List contains what?
Value Next Pointer
- In a linked list
The first node is ... ? The last node is ... ? The first node is Head The last node is Tail
Q9. How do we keep the connection to a linked list?
By a variable pointing to the head
- Simple Pseudo code of Singly LinkedListNode public class LinkedListNode {
public int value; public LinkedListNode next;
public LinkedListNode(int value) { this.value = value;
We could build a singly linked list like this:
LinkedListNode a = new LinkedListNode(5); LinkedListNode b = new LinkedListNode(1); LinkedListNode c = new LinkedListNode(9);
a.next = b; b.next = c;
- Simple Pseudo code of Doubly LinkedListNode
public class LinkedListNode {
public int value; public LinkedListNode next; public LinkedListNode previous;
public LinkedListNode(int value) { this.value = value;
So we could build a doubly linked list like this:
LinkedListNode a = new LinkedListNode(5); LinkedListNode b = new LinkedListNode(1); LinkedListNode c = new LinkedListNode(9);
// put b after a a.next = b; b.previous = a; // put c after b b.next = c; c.previous = b;
- Time Complexity for Insert /remove from the front
- Constant
Q13. Constant Time to insert/remove from the back is when?
Tail and Doubly LInked List
Q14. Constant Time to insert between node when?
ADT and Stack
- Abstraction Representation of an entity with only it's most relevant attributes.
- Encapsulation Having modules whose state is accessed through its methods only.
- Implementation Code written in methods
- Data Hiding Decoupling implementation from interface. -Make all fields private except methods that others will use ( hide state and make interface available) Advantage : Low Coupling (Implementation can change without affecting others)
- Encapsulation Modularity + Data Hiding
- Modularity Keep implementation and state in one module (class) Advantage: High Cohesion (Everything associated with the call is together)
- Abstract Data Types (ADT) a data type with values and operations that are not defined in the language by default.
- Data Structure A programming construct used to implement ADTs. -Mechanism for organizing the data that is the ADT is encapsulating -Data structures should be hidden by the API(methods) of the ADT
- Stack A Stack is a Last In First Out (LIFO) data structure. It supports two basic operations called push and pop. The push operation adds an element at the top of the stack, and the pop operation removes an element from the top of the stack. The Stack class extends Vector which implements the List interface.
Queues
Q1. What is a queue?
An ADT with FIFO characteristics
Q2. What does FIFO stand for?
First In First Out
- Where does insertion occur in a queue
- The rear
Related CS301 files
All CS301 files →- CS301 Midterm Short Notes 2021 Midterm PDF 1.3 MB
- CS301 Midterm Solved Grand Quiz 2020 Midterm PDF 3.8 MB
- CS301 Midterm Past Papers Fall 2019 Midterm DOCX 17 KB
- CS301 Midterm Past Papers Spring 2019 Midterm DOCX 19 KB
- CS301 Official Handouts Official handout PDF 3.4 MB Free
- CS301 Quiz 4 2023 by Nida Khan Quiz PDF 1.6 MB
Get more out of VUBuddy, for free
- Unlimited downloads
- The explanation behind every MCQ answer
- Study offline on slow data
- 30 downloads a day instead of 3
- Sign in and buy Pro Semester here
One Pro Semester membership works in both the extension and the app.