Advanced Data Structures Exam Questions - Gracious University
This document outlines the details for the first semester examination for the course 'Advanced Data Structure' (SWE 235) scheduled for January 2025, including instructions and a series of questions related to data structures and algorithms. It covers topics such as array disadvantages, time complexities for various operations, and functionalities of linked lists. Additionally, it includes sections for definitions and conceptual questions about programming lists and abstract data types (ADTs).
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
25 views
Advanced Data Structures Exam Questions - Gracious University
This document outlines the details for the first semester examination for the course 'Advanced Data Structure' (SWE 235) scheduled for January 2025, including instructions and a series of questions related to data structures and algorithms. It covers topics such as array disadvantages, time complexities for various operations, and functionalities of linked lists. Additionally, it includes sections for definitions and conceptual questions about programming lists and abstract data types (ADTs).
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5
ACADEMIC YEAR 2024/2025
TYPE OF EXAMINATION: FIRST SEMESTER EXAM
COURSE TITLE: ADVANCED DATA STRUCTURE COURSE CODE: SWE 235 COURSE INSTRUCTOR: Mr. EFUETLANCHA CLINTON DATE: January 2025 TIME ALLOWED: 1 Hour INSTRUCTIONS: Please you are required to answer ALL questions. You are reminded of the necessity for good English and orderly presentation of your work.
Section A
1. Which of the following is not a disadvantage class Node
to the usage of array? { a) Fixed size protected Node next; b) There are chances of wastage of memory protected Object ele; space if elements inserted in an array are lesser Node(Object e,Node n) than the allocated size { c) Insertion based on position ele = e; d) Accessing elements at specified positions next = n; 2. What is the time complexity of inserting at } the end in dynamic arrays? public void setNext(Node n) a) O(1) { b) O(n) next = n; c) O(logn) } d) Either O(1) or O(n) public void setEle(Object e) 3. What is the time complexity to count the { number of elements in the linked list? ele = e; a) O(1) } b) O(n) public Node getNext() c) O(logn) { d) O(n2) return next; 4. Which of the following performs deletion of } the last element in the list? Given below is the public Object getEle() Node class. { return ele; if(size == 0) } return null; } Node cur; class SLL Node temp; { cur = head; Node head; while(cur != null) int size; { SLL() cur = cur.getNext(); { temp = cur; size = 0; } } temp.setNext(null); } return cur; a) } public Node removeLast() d) { public void removeLast() if(size == 0) { return null; if(size == 0) Node cur; return null; Node temp; Node cur; cur = head; Node temp; while(cur.getNext() != null) cur = head; { while(cur.getNext() != null) temp = cur; { cur = cur.getNext(); cur = cur.getNext(); } temp = cur; temp.setNext(null); } size--; temp.setNext(null); return cur; return cur; } } b) 5. What is the functionality of the following public void removeLast() code? { public void function(Node node) if(size == 0) { return null; if(size == 0) Node cur; head = node; Node temp; else cur = head; { while(cur != null) Node temp,cur; { for(cur = head; (temp = temp = cur; cur.getNext())!=null; cur = temp); cur = cur.getNext(); cur.setNext(node); } } temp.setNext(null); size++; return cur; } } a) Inserting a node at the beginning of the list c) b) Deleting a node at the beginning of the list public void removeLast() c) Inserting a node at the end of the list { d) Deleting a node at the end of the list for(int i=1; i<pos; i++) { 6. What is the space complexity for deleting a temp = temp.getNext(); linked list? } a) O(1) temp.setNext(temp.getNext()); b) O(n) } c) Either O(1) or O(n) size--; d) O(logn) } c) 7. How would you delete a node in the singly public void delete(int pos) linked list? The position to be deleted is given. { a) if(pos < 0) public void delete(int pos) pos = 0; { if(pos > size) if(pos < 0) pos = size; pos = 0; if( size == 0) if(pos > size) return; pos = size; if(pos == 0) if( size == 0) head = head.getNext(); return; else if(pos == 0) { head = head.getNext(); Node temp = head; else for(int i=1; i<pos; i++) { { Node temp = head; temp = for(int i=1; i<pos; i++) temp.getNext().getNext(); { } temp = temp.getNext(); } temp.setNext(temp.getNext().getNext()); } temp.setNext(temp.getNext().getNext()); size--; } } size--; d) } public void delete(int pos) b) { public void delete(int pos) if(pos < 0) { pos = 0; if(pos < 0) if(pos > size) pos = 0; pos = size; if(pos > size) if( size == 0) pos = size; return; if( size == 0) if(pos == 0) return; head = head.getNext(); if(pos == 0) else head = head.getNext(); { else Node temp = head; { for(int i=0; i<pos; i++) Node temp = head; { temp = temp.getNext(); size++; } cur = cur.getNext(); } temp.setNext(temp.getNext().getNext()); } } d) size--; public int length(Node head) } { 8. Which of these is not an application of a int size = 0; linked list? Node cur = head; a) To implement file systems while(cur!=null) b) For separate chaining in hash-tables { c) To implement non-binary trees size++; d) Random Access of elements cur = cur.getNext().getNext(); } 9. Which of the following piece of code has the return size; functionality of counting the number of } elements in the list? 10. How do you insert an element at the a) beginning of the list? public int length(Node head) a) { public void insertBegin(Node node) int size = 0; { Node cur = head; node.setNext(head); while(cur!=null) head = node; { size++; size++; } cur = cur.getNext(); b) } public void insertBegin(Node node) return size; { } head = node; b) node.setNext(head); public int length(Node head) size++; { } int size = 0; c) Node cur = head; public void insertBegin(Node node) while(cur!=null) { { Node temp = head.getNext() cur = cur.getNext(); node.setNext(temp); size++; head = node; } size++; return size; } } d) c) public void insertBegin(Node node) public int length(Node head) { { Node temp = head.getNext() int size = 0; node.setNext(temp); Node cur = head; node = head; while(cur!=null) size++; { } SECTION B
1.) What is a list in programming?
2.) What does ADT stand for?
3.) Name one common operation on lists.
4.) What are some examples of ADTs?
5.) How does a list differ from an ADT?
6.) What are some common operations performed on lists?
7.) Why are ADTs important in software design?
8.) How does the concept of homogeneity apply to lists?
9.) What data structure is commonly used to implement lists?
10.) What is the purpose of the resize method in the array list implementation?
SECTION C
1. Construct an adjacency matrix using the graph given below −
2. Create an adjacency list using the graph provided below.