PROBLEM SOLVING TECHNIQUES
By
Dept. of CSE
PVPSIT, Kanuru.
PRASAD V. POTLURI SIDDHARTHA INSTITUTE OF TECHNOLOGY
B. Vinay Kumar
Thursday, April 17, 2025
LINEAR SEARCH
PVPSIT (Autonomous)
Problem Solving Techniques
B. Vinay Kumar
Thursday, April 17, 2025
PVPSIT (Autonomous)
Problem Solving Techniques
B. Vinay Kumar
Thursday, April 17, 2025
PVPSIT (Autonomous)
Problem Solving Techniques
B. Vinay Kumar
Thursday, April 17, 2025
Case | Time Complexity |
Best Case | O(1) |
Average Case | O(n) |
Worst Case | O(n) |
PVPSIT (Autonomous)
Problem Solving Techniques
B. Vinay Kumar
Thursday, April 17, 2025
Space Complexity | O(1) |
PVPSIT (Autonomous)
Problem Solving Techniques
a. if the value sought is equal to current array value then
(a.1) Assign i to pos and return pos
a’. increment i value by 1
4. If the pos is equal to -1 then write out Value not found
else write out value found at pos
B. Vinay Kumar
Thursday, April 17, 2025
Algorithm Description
PVPSIT (Autonomous)
Problem Solving Techniques
Otherwise print “Value is present at ith index”
B. Vinay Kumar
Thursday, April 17, 2025
Algorithm
PVPSIT (Autonomous)
Problem Solving Techniques
A[1..n] = [70, 40, 30, 11, 57, 41, 25, 14, 52]
key := 41
pos = -1
for i = 1 to n do
If a[i] = key then
begin
pos = i
return pos
end
If pos = -1 then display “Element is not found” else
Display “Element is found at pos”
B. Vinay Kumar
Thursday, April 17, 2025
Pseudo-code
PVPSIT (Autonomous)
Problem Solving Techniques
B. Vinay Kumar
Thursday, April 17, 2025
PVPSIT (Autonomous)
Problem Solving Techniques
B. Vinay Kumar
Thursday, April 17, 2025
PVPSIT (Autonomous)
Problem Solving Techniques