0% found this document useful (0 votes)
4 views

cs301-lecture 1

Uploaded by

fazilabibi344
Copyright
© © All Rights Reserved
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% found this document useful (0 votes)
4 views

cs301-lecture 1

Uploaded by

fazilabibi344
Copyright
© © All Rights Reserved
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/ 9

CS301-Data Structures

Multiple Choice Questions


Lecture No. 01

1. What is an array?
A) Collection of variables of different types
B) Collection of variables of the same type
C) Collection of functions
D) Collection of operators

Answer: B) Collection of variables of the same type

2. Which statement declares an integer array of six elements?


A) int x(6);
B) int x[6];
C) int x(6)[];
D) int[6] x;

Answer: B) int x[6]

3. What is the index range for an array of size 6?


A) 1-6
B) 0-5
C) 0-6
D) -5 to 0

Answer: B) 0-5
4. How are array elements stored in memory?
A) Randomly
B) Contiguously
C) Alphabetically
D) Numerically

Answer: B) Contiguously

5. Which operator dynamically allocates memory?


A) new
B) delete
C) malloc
D) calloc

Answer: A) new

6. What does createList() function do?


A) Create a copy of a list
B) Clear a list
C) Create a new empty list
D) Remove an element

Answer: C) Create a new list


7. Which function replaces an element at a given position?
A) update(X, position)
B) insert(X, position)
C) remove(position)
D) get(position)

Answer: A) update(X, position)

8. What does clear() function do?


A) Remove one element
B) Clear entire list
C) Copy a list
D) Insert an element

Answer: B) Clear entire list

9. What does start() function do?


A) Move to last element
B) Move to next element
C) Move to first element
D) Move to previous element

Answer: C) Move to first element

10. Which function moves the current pointer backward?


A) next()
B) back()
C) start()
D) tail()

Answer: Back

11. What does copy() function achieve?


A) Duplicate element
B) Set one list as another's copy
C) Remove element
D) Insert element

Answer: B) Set one list as another's copy

12. Where does insert(X, ?) add an element?


A) Beginning
B) End
C) Specific position
D) Randomly

Answer: C) Specific position

13. What does get(?) function retrieve?


A) Element's index
B) List length
C) Element at specified position
D) List copy
Answer: C) Element at specified position

14. What does find(X) determine?


A) Element's index
B) List length
C) Element existence
D) List copy

Answer: C) Element existence

15. What does length() return?


A) Element count
B) List index
C) Element value
D) List copy

Answer: A) Element count

16. What does tail() function accomplish?


A) Move to first element
B) Move to previous element
C) Move to last element
D) Move forward one element

Answer: C) Move to last element


17. What does next() function do?
A) Move backward one element
B) Move to first element
C) Move forward one element
D) Move to last element

Answer: C) Move forward one element

18. What type of data structure is a list?


A) Ordered
B) Unordered
C) Generic
D) All of the above

Answer: D) All of the above

19. Which operation can be performed on a list?


A) Insertion
B) Deletion
C) Sorting
D) All of the above

Answer: D) All of the above

20.What is an lvalue variable?


A) Variable with no memory
B) Variable with memory
C) Constant
D) Function

Answer: B) Variable with memory

21. How is dynamically allocated memory released?


A) delete
B) free
C) malloc
D) calloc

Answer: A) delete

22. What does length() function return?


A) Element at position
B) List's length
C) Element's index
D) Current position

Answer: B) List's length

23. Which function checks if an element exists?


A) find(X)
B) get(position)
C) insert(X, position)
D) remove(position)

Answer: A) find(X)

24. Which programming language will be used for implementation?


A) Java
B) Python
C) C++
D) C#

Answer: C) C++

25. Which list type uses numerical indexing?


A) Array-based
B) Pointer-based
C) Current-pointer-based
D) Dynamic

Answer: A) Array-based

26. Which list type uses a "current" marker?


A) Array-based
B) Pointer-based
C) Current-pointer-based
D) Dynamic
Answer: C) Current-pointer-based

You might also like