Posts

Showing posts from May, 2022

GREEDY METHOD

  UNIT :3 - THE GREEDY METHOD Knapsack Problem, Minimum Cost Spanning Tree, Single Source Shortest Path THE GENERAL METHOD The Greedy Method is a problem-solving approach used in designing algorithms. It works by making a series of choices, each of which is the best choice at the moment, with the hope that these local choices will lead to the global optimal solution.   Key Steps in the Greedy Method: 1. Initialization: Start with an empty or initial solution. 2. Selection: At each step, choose the option that looks best. 3. Feasibility Check: Ensure that the choice is valid and keeps the solution feasible. 4. Repeat: Continue until the problem is solved or all choices are exhausted.   When does the Greedy Method work? The greedy method works if the problem satisfies the Greedy-Choice Property (local optimal choices lead to a global optimum) and Optimal Substructure (optimal solutions to subproblems combine to form an optimal solution to the whole problem).   KNAPSACK...

Linked List representations of Employee Records

  //Linked List representations of Employee Records   #include<stdlib.h> #include<stdio.h> struct emp {             int empno;             char *empname;             long int salary;             struct emp *next; }*start = NULL;   void insert() {             struct emp *temp,*ptr;             temp = malloc(sizeof(struct emp));             printf("\n Employee Number: ");             scanf("%d",&temp->empno);             printf("\n Empl...

ANALYSIS & DESIGN OF ALGORITHMS (23PCSC01) - TOPIC-WISE - MCQ

  ANALYSIS & DESIGN OF ALGORITHMS (2 3PCSC01) UNIT 1 Algorithm Definition and Specification 1. What is an algorithm?   A. A set of mathematical equations   B. A stepbystep procedure to solve a problem   C. A programming language   D. A type of hardware component   Answer: B   2. Which of the following is NOT a characteristic of an algorithm?   A. Finiteness   B. Definiteness   C. Ambiguity   D. Effectiveness   Answer: C   Space Complexity and Time Complexity 3. What does space complexity of an algorithm measure?   A. The amount of time an algorithm takes   B. The number of operations an algorithm performs   C. The amount of memory required by an algorithm   D. The size of the input data   Answer: C   Asymptotic Notations 4. Which of the following is the tightest upper bound for an algorithm's growth?     A. BigO   ...