Sie sind auf Seite 1von 13

Algorithm for creating a sequential file with atleast 5 records, each record having the structure shown below.

USN NAME Marks1 Marks2 Marks3 Non-Zero 25 char Positive Positive Positive Write the necessary functions: 1. To display all the records in the file. 2. To search for a specified record based on the USN. Step 1: Start Step 2: [Global Declaration] Declaring Structure and its member to read the Name, USN, and marks in three subject. Step 3: Initializing Step 4: Reading the values for Name, USN, and marks in three subject and writing into the FILE. Step 5: [Invoke the function] using the choice 1. Display 2. Search 3. Quit Step 6: Switch to particular case depending on the Choice (Step 7, Step 8, or Step 9) Step 7: Display the contents of the Student with his Name, USN, and marks in threes subject. Step 8: Search the contents of the Student taking the USN as a input. Step 9: Quit in case of any other key is pressed. Step 10: Stop

Algorithm to demonstrate the following functions 1. NewStrcpy that does the same job as strcpy. 2. NewStrcat that does the same job as strcat. Step 1: Start Step 2: [Condition to input the String] Step 3: Initialize the variable to 0 Step 4: Read the Choice to Perform the Operations Step 5: Switching to the required Case using the entered Choice (Step 5, Step 6) Step 6: Copying the String from one variable to another variable. Step 7: Concatenate the String from the two input read. Step 8: Quit in case of any other key is pressed. Step 9: Stop.

Algorithm to understand the Stack operation (Push, Pop, Display) Step 1: Start Step 2: Declaring the Global Variables. Step 3: Initializing Step 4: Read the Choice to Perform the Operations. 1. Push 2. Pop 3. Display 4. Exit Step 5: Invoke the respective Function. (Step 6, Step 7, Step 8, Step9) Step 6: [Push Operation] Push the elements to the Stack. Step 7: [Pop Operation] Pop the elements from the Stack. Step 8: [Display Operation] Display the contents of the Stack. Step 9: Quit in case of any other key is pressed. Step 10: Stop.

Algorithm to convert and print a given valid fully parenthesized infix arithmetic expression to postfix expression. The term consist of single character operands and binary operations +, -, * , /. Step 1: Start Step 2: Declare the global variables. Step 3: Initializing Step 4: Read the Infix Expression. Step 5: Push # into the Stack. Step 6: Convert the Infix to Postfix Expression. (Call Step 7) Step 7: Check the Precedence of the Symbol encountered. [Switch (var[TOS])] Step 8: Switch according to the choice entered. Case +, -, * , /, ^. And return the respective value. Step 9: Push and Pop the elements accordingly. Step 10: Print the Postfix Expression. Step 11: Stop.

Algorithm to evaluate a valid suffix/postfix expression using stack. Assuming that the suffix/postfix expression is read as a single line consisting of non negative single digit operands and binary arithmetic operation. The operators are *, /, +, - Step 1: Start Step 2: Declare the global variables. Step 3: Initializing Step 4: Read the Postfix Expression. Step 5: Evaluate the Expression [using the function isalpha (var [limit])] Step 6: Print the Expression. Step 7: Evaluate the expression using the values entered. Case *, / , + , - Step 8: Push and Pop the elements accordingly. Step 9: Print the value of the expression. Step 10: Stop.

Algorithm to stimulate the working of a circular queue of integers using an array, perform the following operations 1. Insert 2. Delete. 3. Display Step 1: Start. Step 2: Global Declaration. Step 3: Initializing. Step 4: Read the option to perform on the Circular Queue. Step 5: Switch to the respective cases to call the functions to perform the operation on a Circular Queue. (Step 6, Step 7, Step 8, Step 9) Step 6: Insert Operation into a Circular Queue. Step 7: Deletion form a Circular Queue. Step 8: Display the elements in a Circular Queue. Step 9: Quit in case of any other key is pressed. Step 10: Stop.

Algorithm for using the dynamic variables and pointer to construct a single linked list consists of the following information in each node: student id, name and semester. The operation to be supported are : 1. Insert operation @ front end of the list 2. Insert operation @ back end of the list 3. Insert operation @ required position of the list 4. Deleting the node based on the student id. 5. Display the nodes of the Linked List Step 1: Start. Step 2: Global Declaration. Step 3: Local Declaration. Step 4: Read the Choice to perform the operation on Single Linked List. (Inserting @ front, back and any position of the List, deleting the node, searching a node, and displaying the node.) Step 5: Input Student information. Step 6: Switch to the Cases. (Step 7, Step 8, Step 9, Step 10, Step 11) 1. Insert operation @ front end of the list 2. Insert operation @ back end of the list 3. Insert operation @ required position of the list 4. Deleting the node based on the student id. 5. Display the nodes of the Linked List Step 7: Function to insert the data @ front end. Step 8: Function to Insert the data @ back end. Step 9: Function to Insert the data @ required position. Step 10: Function to Delete the data. (Student record). Step 11: Function to Display the data. Step 12: Free the memory allocation. Step 13: Stop.

Algorithm to use the dynamic variable and pointer to construct a stack of integers using singly linked list and to perform the following operations. 1. Push 2. Pop 3. Display

Step 1: Start. Step 2: Global Declaration. Step 3: Initializing Step 4: Read the Choice from the user 1. Push 2. Pop 3. Display 4. Exit Step 5: Invoke the particular function depending on the entered choice (Step 6, Step 7, Step 8, and Step 9) Step 6: Function to perform Insert Operation. [use malloc] Step 7: Function to perform Delete Operation [free the memory] Step 8: Function to perform Display Operation Step 9: Quit in case of any other key is pressed. Step 10: Stop.

Algorithm using the dynamic variables and pointers to construct a queue of integers using singly linked list and to perform the following operations. 1. Insert 2. Delete 3. Display Step 1: Start. Step 2: Declare the Structure Queue. Step 3: Initialize. Step 4: Display the choice to perform the operations. 1. Insert. 2. Delete. 3. Display. 4. Exit Step 5: the choice and Switch to the respective cases(Step 6, Step 9, Step 10) [To insert the element with no parameters] Step 6: Initialize using malloc. Step 7: Read data from the user. Step 8: Check the condition and insert the data. [To Delete the element with no parameters] Step 9: Check the condition and delete the data. [To Display the element with no parameters Step 10: Initialize Step 11: Check for the condition whether the queue is empty. And then display the elements of the Queue. Step 12: Stop

Algorithm to support the following operations on a doubled linked list where each node consists of integers. 1. Create a double linked list by adding each node @ front end 2. Insert the new node @ the left of the node. 3. Delete a node of given data 4. Display the nodes.

Step 1: Start. Step 2: Declare a Student node. Step 3: Display the choice to perform the operations on Double linked list 1. Add @ front end 2. Insert left of a node 3. Delete node if given data. 4. Display. 5. Exit Step 4: Read the choice and Switch to the respective cases.(Step 5, Step 8, Step 11, Step 14, and Step 15) [To Insert @ front end with no parameters] Step 5: Read the data. Step 6: Initialize. Step 7: Check the condition and insert the element @ front end. [To Insert @ left of a node] Step 8: Read the data. Step 9: Initialize. Step 10: Check for the condition and insert the element @ left of a node. [To Delete a node] Step 11: Read the value. Step 12: Initialize. Step 13: Check the condition and Delete the element. [To Display the element with no parameters] Step 14: Check for the condition and display the elements of the Doubled Linked List. Step 15: Quit in case of any other key is pressed. Step 16: Stop

Algorithm to conduct a binary tree of integers to traverse the tree using all the given below method. 1. Inorder 2. Preorder 3. Postorder

Step 1: Start Step 2: Declare a structure node. Step 3: Read the number of element in a tree. Step 4: Check the condition and enter the elements in Tree. [Use Malloc] [Inorder using the Struct node and head as a parameter] Step 5: Check the condition and insert the element appropriately in the position required. [Preorder using the Struct node and head as a parameter] Step 6: Check the condition and insert the element appropriately in the position required. [Postorder using the Struct node and head as a parameter] Step 7: Check the condition and insert the element appropriately in the position required. Step 8: Stop.

Algorithm to a recursive C Program for searching an element on a given list of integer using Binary Search method. Step 1: Start Step 2: Declare the Global Variables Step 3: Read the no of elements in an array. Step 4: Check the condition and read the elements into an array. Step 5: Invoke the function. (Step 6) [To Perform Binary Search] Step 6: Read the Element to be searched. Step 7: Calculate the mid term. Step 8: Search the element accordingly (Two conditions are: 1. Element to be searched is < mid 2. Element to be searched is > mid Step 9: Display the appropriated message. Step 10: Stop.

Algorithm to a recursive C program for solving the Tower of Hanoi.

Step 1: Start Step 2: Read the number of disks. Step 3: Invoke the recursive function. Step 4: Check for the condition and move the disks 1. move (n-1)th disks from A-B 2. move nth disk from B-C 3. move (n-1)th disk form A-C Step 5: Display the Tower of Hanoi Elements arranged in Last Pole. Step 6: Stop.

Das könnte Ihnen auch gefallen