Xirius-ArraysStringsandAlgorithm2-COS201.pdf

Course: COS201 • Xirius AI

1. Which sorting algorithm is particularly efficient for small or nearly sorted datasets?

2. Which of the following correctly accesses the first character in a string `name` in Python?

3. What is the main purpose of the base case in a recursive algorithm?

4. What is recursion in programming?

5. What is the result of the string operation len("Hello") in Python?

6. Which of the following is a characteristic of linear search?

7. Why is a base case essential in a recursive algorithm?

8. How would you access the element in row 1, column 2 of a 2D array `int marks[2][3]`?

9. What is the result of the Python expression: `len("Hello World")`?

10. What is the primary purpose of sorting?

11. What is the base case in a recursive function?

12. What is a characteristic of arrays related to memory?

13. What is a disadvantage of bubble sort?

14. What is a key characteristic that differentiates a recursive algorithm from an iterative one?

15. What is an array?

16. What happens during the traversal operation of an array?

17. Which of the following is true about the base case in recursion?

18. What is traversing an array?

19. In the factorial recursive function, what does `factorial(0)` return?

20. Which example correctly declares a one-dimensional array in C language?

21. What is the factorial of 5 as calculated by the recursive function `factorial(5)`?

22. What does the Python expression "Programming"[0:6] return?

23. Which searching method requires a sorted list?

24. What is a two-dimensional array?

25. Which operation is NOT typically common in string handling?

26. Which of the following correctly extracts a substring in Python from index 0 to 5?

27. What is the output of the Python code `"Programming"[0:6]`?

28. What does indexing in most programming languages start from in arrays?

29. Which Python function will return the index of character 'p' in the string "Computer"?

30. In the context of strings, what does concatenation mean?

31. Which of the following is NOT a direct benefit of using arrays?

32. What is a common characteristic of strings in many languages?

33. In string searching, what does the C function `strstr()` do?

34. What does the Python method `str.find()` do?

35. What is the valid way to declare a string in Java?

36. If factorial(0) returns 1, what is the role of this specific condition within the recursive factorial function?

37. What is one major disadvantage of bubble sort when sorting large datasets?

38. What is the purpose of the insertion operation on an array?

39. What type of data is stored in arrays?

40. Which function in C returns the length of a string?

41. Which of the following best describes the process of selection sort?

42. What must be true for binary search to work correctly?

43. What is a key advantage of binary search compared to linear search?

44. Which of these statements about strings in many programming languages is TRUE?

45. What does the bubble sort algorithm do during its passes?

46. Which of the following is NOT a characteristic of recursive algorithms?

47. What data type constraint do arrays have?

48. How can two arrays be merged in Python?

49. How are elements in an array accessed?

50. How do you concatenate two strings `str1` and `str2` in Python?