-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathbasic-program-questions.txt
More file actions
164 lines (95 loc) · 5.7 KB
/
basic-program-questions.txt
File metadata and controls
164 lines (95 loc) · 5.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# C Program question
1. Write a c program to check given number is perfect number or not.
2. Write a c program to check given number is Armstrong number or not.
3. Write a c program to check given number is prime number or not.
4. Write a c program to reverse any number.
5. Write a c program to check given number is strong number or not.
6. Write a c program to find out sum of digit of given number.
7. Write a c program to check given number is palindrome number or not.
8. Write a c program to check given string is palindrome number or not.
9. Write a c program to find out power of number.
10. Write a c program to add two numbers without using addition operator.
11. Write a c program to subtract two numbers without using subtraction operator.
12. Write a c program to find largest among three numbers using binary minus operator.
13. Write a c program to find largest among three numbers using conditional operator
14. Write a c program to find out generic root of any number.
15. Write a c program to solve quadratic equation.
16. Write a c program which passes one dimension array to function.
17. Write a c program which passes two dimension array to function.
18. Write a c program which passes structure to function.
19. Write a c program for Floyd’s triangle.
20. Write a c program to print Pascal triangle.
21. Write a c program to generate multiplication table.
22. Write a c program to get factorial of given number.
23. Write a c program to find out prime factor of given number.
24. Write a c program to find out NCR factor of given number.
25. Write a c program to print Fibonacci series of given range.
26. Write a c program to print ASCII value of all characters.
27. Write a c program to check given year is leap year or not.
28. Write a c program which takes password from user.
29. Write a scanf function in c which accept sentence from user.
30. Write a scanf function in c which accept paragraph from user.
31. Write a c program to print the all prime numbers between 1 to 300.
32. Big list of c program examples
General
Find the most frequent integer in an array
Find pairs in an integer array whose sum is equal to 10 (bonus: do it in linear time)
Given 2 integer arrays, determine of the 2nd array is a rotated version of the 1st array. Ex. Original Array A={1,2,3,5,6,7,8} Rotated Array B={5,6,7,8,1,2,3}
Write fibbonaci iteratively and recursively (bonus: use dynamic programming)
Find the only element in an array that only occurs once.
Find the common elements of 2 int arrays
Implement binary search of a sorted array of integers
Implement binary search in a rotated array (ex. {5,6,7,8,1,2,3})
Use dynamic programming to find the first X prime numbers
Write a function that prints out the binary form of an int
Implement parseInt
Implement squareroot function
Implement an exponent function (bonus: now try in log(n) time)
Write a multiply function that multiples 2 integers without using *
HARD: Given a function rand5() that returns a random int between 0 and 5, implement rand7()
HARD: Given a 2D array of 1s and 0s, count the number of "islands of 1s" (e.g. groups of connecting 1s)
Strings
Find the first non-repeated character in a String
Reverse a String iteratively and recursively
Determine if 2 Strings are anagrams
Check if String is a palindrome
Check if a String is composed of all unique characters
Determine if a String is an int or a double
HARD: Find the shortest palindrome in a String
HARD: Print all permutations of a String
HARD: Given a single-line text String and a maximum width value, write the function 'String justify(String text, int maxWidth)' that formats the input text using full-justification, i.e., extra spaces on each line are equally distributed between the words; the first word on each line is flushed left and the last word on each line is flushed right
Trees
Implement a BST with insert and delete functions
Print a tree using BFS and DFS
Write a function that determines if a tree is a BST
Find the smallest element in a BST
Find the 2nd largest number in a BST
Given a binary tree which is a sum tree (child nodes add to parent), write an algorithm to determine whether the tree is a valid sum tree
Find the distance between 2 nodes in a BST and a normal binary tree
Print the coordinates of every node in a binary tree, where root is 0,0
Print a tree by levels
Given a binary tree which is a sum tree, write an algorithm to determine whether the tree is a valid sum tree
Given a tree, verify that it contains a subtree.
HARD: Find the max distance between 2 nodes in a BST.
HARD: Construct a BST given the pre-order and in-order traversal Strings
Stacks, Queues, and Heaps
Implement a stack with push and pop functions
Implement a queue with queue and dequeue functions
Find the minimum element in a stack in O(1) time
Write a function that sorts a stack (bonus: sort the stack in place without extra memory)
Implement a binary min heap. Turn it into a binary max heap
HARD: Implement a queue using 2 stacks
Linked Lists
Implement a linked list (with insert and delete functions)
Find the Nth element in a linked list
Remove the Nth element of a linked list
Check if a linked list has cycles
Given a circular linked list, find the node at the beginning of the loop. Example: A-->B-->C --> D-->E -->C, C is the node that begins the loop
Check whether a link list is a palindrome
Reverse a linked list iteratively and recursively
Sorting
Implement bubble sort
Implement selection sort
Implement insertion sort
Implement merge sort
Implement quick sort