Data Structure and Algorithm
Data Structure and Algorithm
ASSIGNMENT #1
Searching:
Algorithms like binary search and linear search help locate specific elements
within data structures such as arrays or linked lists.
Sorting:
Algorithms such as quick sort, merge sort, and bubble sort organize data in a
specific order (ascending or descending) within structures like arrays or lists.
Insertion:
Deletion:
Traversal:
Algorithms like in-order, pre-order, and post-order traversal are used to visit all
the nodes in tree structures systematically.
Merging:
Algorithms can combine two or more data structures, such as merging two
sorted arrays into a single sorted array.
Graph Algorithms:
Algorithms like Dijkstra's and Kruskal's help in finding the shortest path or
minimum spanning tree in graph data structures.
Dynamic Programming:
Hashing:
Balancing:
Defining the Scope: Knowing the problem domain helps you define the
boundaries of your algorithm. What are the specific inputs and outputs? What
are the constraints and assumptions?
Choosing the Right Approach: Different problem domains call for different
algorithmic approaches. For example, a sorting algorithm for a small list of
numbers might be different from one used to sort a massive database.
Evaluating Solutions: Knowing the problem domain allows you to evaluate the
effectiveness of your algorithm.
Step 1 − START
Step 8 − STOP
Write a C program to find the largest of three numbers using Conditional statement(IF and
else).
Algorithm:
Step 1 − START
Step 2 − Declare four integer variables: num1, num2, num3, and largest
Step 4 − Read the three numbers entered by the user and store them in num1, num2, and
num3 respectively
Step 5 − If num1 is greater than or equal to both num2 and num3: - Assign the value of
num1 to largest
Step 6 − Else if num2 is greater than or equal to both num1 and num3: - Assign the value of
num2 to largest
Step 9 − STOP
Step 1 − START
Step 4 − Read the length entered by the user and store it in the length variable
Step 6 − Read the width entered by the user and store it in the width variable
Step 7 − Calculate the area of the rectangle by multiplying length and width and store the
result in the area variable
Step 8 − Print the calculated area of the rectangle, formatted to two decimal places
Step 9 − STOP