1. The document describes an algorithm design and analysis lab file submitted by Suraj Kumar to Anuradha Chug.
2. It contains 19 programs implementing various algorithms including searching, sorting, graph algorithms like BFS, DFS, Kruskal, Prim's, and string matching algorithms.
3. The programs are written in C++ and implement algorithms like linear search, binary search, selection sort, bubble sort, insertion sort, merge sort, quicksort, bucket sort, radix sort, counting sort, breadth first search, depth first search, Kruskal, Prim's, Dijkstra, and string matching algorithms.
1. The document provides a lab manual for computer networks and operating systems labs containing 8 programs to implement various networking and security algorithms.
2. The programs include implementing data link layer framing methods, CRC polynomials, Dijkstra's shortest path algorithm, distance vector routing, DES encryption, breaking the DES code, and RSA encryption/decryption.
3. The document contains instructions for 8 programs to implement computer network and security algorithms as part of a lab course covering topics like data link layer, routing, encryption, and public key cryptography.
This document contains 8 C programming code examples demonstrating various scheduling algorithms:
1. First Come First Serve scheduling
2. Non-preemptive Shortest Job First scheduling
3. Round Robin scheduling
4. Priority scheduling
5. Banker's algorithm for deadlock avoidance
6. Producer-consumer problem synchronization
7. Dekker's algorithm for mutual exclusion
Each program example includes comments explaining the algorithm and includes functions to calculate waiting times, turnaround times, and other metrics.
This document contains programs and algorithms for simulating different CPU scheduling algorithms like FCFS, SJF, Priority and Round Robin. It also contains a program for implementing the Producer-Consumer problem using semaphores and an algorithm for implementing optimal page replacement.
The document contains 10 programs related to sorting and graph algorithms. Program 1-7 implement different sorting algorithms - insertion sort, selection sort, heap sort, quick sort, counting sort, merge sort and radix sort. Program 8 implements the greedy knapsack problem. Program 9 implements the travelling salesman problem. Program 10 implements Kruskal's algorithm to find the minimum spanning tree of a graph.
This document contains 15 experiments related to computer graphics. Each experiment includes the coding and output for programs that draw basic shapes like lines, circles, and ellipses using different algorithms like DDA, Bresenham, and midpoint. Experiment 6 demonstrates rotation of a triangle, 7 translates a line, 8 performs scaling of a line, and 9 shears a rectangle. The programs utilize graphics functions and libraries like initgraph, putpixel, line, rectangle. Each experiment provides the full code solution to visualize and manipulate basic graphics primitives.
The document contains code snippets for different algorithms related to computer graphics clipping and filling. Specifically, it includes code for:
1. Point clipping within a rectangle
2. The Sutherland-Hodgeman polygon clipping algorithm
3. Flood fill and boundary fill algorithms
4. Line clipping using the Liang-Barsky algorithm
5. 3D object projection using an oblique transformation matrix
The document contains code snippets in C++ for graphics programs to draw various shapes and perform transformations like translation, rotation, and scaling using Turbo C++. It includes programs to draw a line, rotate a line, scale a line, display text horizontally and vertically, draw a house, fish, and man cartoon. Each code example contains functions for initialization, input, drawing objects using lines, circles, rectangles, and outputting text.
The document describes programs to implement various operations on singly linked lists including insertion, deletion, counting nodes, creating a list, traversing a list, and copying a list. It provides functions for insertion at the beginning, end, and before/after a given node. Deletion functions remove from the beginning, end, or by item value. Counting returns the total nodes or occurrences of a value. Traversal and copying print or duplicate the list.
1. The document provides a lab manual for computer networks and operating systems labs containing 8 programs to implement various networking and security algorithms.
2. The programs include implementing data link layer framing methods, CRC polynomials, Dijkstra's shortest path algorithm, distance vector routing, DES encryption, breaking the DES code, and RSA encryption/decryption.
3. The document contains instructions for 8 programs to implement computer network and security algorithms as part of a lab course covering topics like data link layer, routing, encryption, and public key cryptography.
This document contains 8 C programming code examples demonstrating various scheduling algorithms:
1. First Come First Serve scheduling
2. Non-preemptive Shortest Job First scheduling
3. Round Robin scheduling
4. Priority scheduling
5. Banker's algorithm for deadlock avoidance
6. Producer-consumer problem synchronization
7. Dekker's algorithm for mutual exclusion
Each program example includes comments explaining the algorithm and includes functions to calculate waiting times, turnaround times, and other metrics.
This document contains programs and algorithms for simulating different CPU scheduling algorithms like FCFS, SJF, Priority and Round Robin. It also contains a program for implementing the Producer-Consumer problem using semaphores and an algorithm for implementing optimal page replacement.
The document contains 10 programs related to sorting and graph algorithms. Program 1-7 implement different sorting algorithms - insertion sort, selection sort, heap sort, quick sort, counting sort, merge sort and radix sort. Program 8 implements the greedy knapsack problem. Program 9 implements the travelling salesman problem. Program 10 implements Kruskal's algorithm to find the minimum spanning tree of a graph.
This document contains 15 experiments related to computer graphics. Each experiment includes the coding and output for programs that draw basic shapes like lines, circles, and ellipses using different algorithms like DDA, Bresenham, and midpoint. Experiment 6 demonstrates rotation of a triangle, 7 translates a line, 8 performs scaling of a line, and 9 shears a rectangle. The programs utilize graphics functions and libraries like initgraph, putpixel, line, rectangle. Each experiment provides the full code solution to visualize and manipulate basic graphics primitives.
The document contains code snippets for different algorithms related to computer graphics clipping and filling. Specifically, it includes code for:
1. Point clipping within a rectangle
2. The Sutherland-Hodgeman polygon clipping algorithm
3. Flood fill and boundary fill algorithms
4. Line clipping using the Liang-Barsky algorithm
5. 3D object projection using an oblique transformation matrix
The document contains code snippets in C++ for graphics programs to draw various shapes and perform transformations like translation, rotation, and scaling using Turbo C++. It includes programs to draw a line, rotate a line, scale a line, display text horizontally and vertically, draw a house, fish, and man cartoon. Each code example contains functions for initialization, input, drawing objects using lines, circles, rectangles, and outputting text.
The document describes programs to implement various operations on singly linked lists including insertion, deletion, counting nodes, creating a list, traversing a list, and copying a list. It provides functions for insertion at the beginning, end, and before/after a given node. Deletion functions remove from the beginning, end, or by item value. Counting returns the total nodes or occurrences of a value. Traversal and copying print or duplicate the list.
The document contains instructions for implementing three network algorithms in C/C++: 1) An error detecting code using CRC CCIT(16 bits), 2) A distance vector algorithm to find suitable transmission paths, and 3) A congestion control algorithm using the leaky bucket method. Sample code is provided for each algorithm to calculate checksums, routing tables, and regulate output rate based on bucket size.
The document contains programs for various data structures and algorithms concepts in C language. It includes programs for 1) array operations using menu driven program, 2) string operations like pattern matching, 3) stack operations using array implementation, 4) infix to postfix conversion, 5) evaluation of postfix expression and tower of Hanoi problem using stack, 6) circular queue operations using array, 7) linked list operations on student data, and 8) doubly linked list operations on employee data. Each section provides the full code for a menu driven program to perform various operations on the given data structure.
The document contains questions and program code snippets related to data structures and algorithms topics.
1) The first section contains a program to remove negative values from a queue using arrays as the underlying data structure.
2) The second section shows functions to implement enqueue, dequeue and display operations on a circular queue using arrays.
3) The third section contains a program to implement an ascending priority queue as a linked list.
This document provides code for a program that converts infix expressions to postfix expressions. It includes functions for pushing and popping elements in a stack, determining operator precedence, and converting an infix string to postfix by processing each character. The main function gets an infix expression from the user, calls the conversion function, and prints the infix and postfix expressions. The program supports operators like +, -, *, /, %, ^ and parentheses.
The document contains questions and program code related to C programming and data structures. Some key points:
- There are questions on sorting arrays, checking for loops in arrays, nested structures, sorting based on dates of birth, and implementing functions for book-author-shelf structures.
- Program code is provided as solutions to these questions, making use of structures, pointers, functions, and linked lists.
- One question asks to write a function to sort records in a linked list based on social security number, and code for creating, displaying, and sorting a linked list is given.
Critical buckling load geometric nonlinearity analysis of springs with rigid ...Salar Delavar Qashqai
This C program performs a geometric nonlinearity analysis of springs with rigid elements under displacement-controlled large deformations. It imports input data, performs an incremental analysis to calculate critical buckling loads, and exports output to Excel and HTML files. The analysis calculates forces, displacements, and critical pressures at each increment until the ultimate displacement is reached. Output graphs the displacement versus critical pressure relationship.
This document provides an overview of weather and climate data for beginners. It discusses accessing weather forecast data through The Weather Company API and visualizing the data in Jupyter notebooks. It also covers obtaining historical weather observations and climate model data from various sources. The document explores using weather data for applications in insurance, energy, retail, and analyzing the relationship between weather and traffic collisions.
This document contains the details of a computer science project completed by Tirthanu Ghosh of class 12A. The project contains 30 programs on different topics written in the Java programming language using BlueJ. It includes programs to generate Pascal's triangle, display numbers in words, calculate an arithmetic progression series and sum, display a calendar for a given month and year, calculate factorials and Fibonacci series using recursion, and more. The document contains the algorithms, code solutions, variable descriptions and outputs for each program. It ends with acknowledgements from Tirthanu thanking those who helped with the project.
Geometric nonlinearity analysis of springs with rigid element displacement co...Salar Delavar Qashqai
This document contains the code for analyzing the geometric and material nonlinearity of springs under displacement-controlled loading. The code imports input data on spring properties and stress-strain behavior, performs an incremental analysis to calculate the base shear and displacement at each step, and exports the results to Excel and MATLAB files. Negative or invalid input values trigger error messages. The analysis calculates the strain, stiffness, and force in each spring at each increment until the ultimate displacement is reached.
Computer Science Investigatory Project class 12thiamtheanupam
This document is a project report submitted by Anupam Anand for their computer science class. It details a project on developing software for a police station. The report includes sections on the purpose, coding, structures used, functions, and a guide Mr. P.K. Gupta who oversaw the project. It describes building a program to store, modify, display and delete criminal records from a police station database.
We have selected to write a program to create a shop billing program which will allow user to input item details such as name, price, quantity, vat etc . And allow further entry of details by user to calculate the total cost. The Last Output will be shown as a bill. You Can see your previous purchases etc.
Assignement of programming & problem solving u.s ass.(1)Syed Umair
The document contains C++ code for various programming problems and their outputs. It includes programs to:
1) Generate a pattern using nested loops; find the first 8 Fibonacci numbers; swap two numbers without a third variable; print patterns of stars.
2) Take input of numbers and find the smallest, check if a number is divisible by 10, print inverted and normal triangles.
3) Calculate an expression, find the sum of the first 6 prime numbers, take student ages and calculate average.
4) Calculate bill amount after applying 10% or 15% discount based on amount.
Nonlinear analysis of braced frame with hinge by hinge method in c programmingSalar Delavar Qashqai
This document is a C program code for nonlinear analysis of braced frames with hinge elements using the hinge method. The program imports input data, calculates the global stiffness matrix and its inverse, determines member forces and displacements through matrix operations, and outputs results to Excel files. Key steps include importing geometry, material properties, and loading, calculating element and system stiffness matrices, inverting the system matrix, determining member forces and displacements, and reporting results.
The document contains code snippets for several C programs including:
1) A program to add complex numbers by defining a structure for complex numbers and taking user input for real and imaginary parts of two numbers and printing their sum.
2) A binary search algorithm implementation to search a sorted array for a key and return its index.
3) A bubble sort algorithm implementation to sort an array of long integers in ascending order by swapping adjacent elements.
The document contains C code for multiple programs that perform various calculations and operations on arrays and numbers. The programs include:
1. Evaluating mathematical expressions by taking input values, performing calculations defined by the expressions, and outputting results.
2. Performing logical operations and comparisons on input values to determine output values based on if/else or switch statements.
3. Calculating factorials, digit sums, reversing numbers, checking for palindromes, and other numeric operations using loops.
4. Generating patterns and diagrams by iterating with for loops.
5. Performing array operations like reversing elements, calculating sums, and swapping arrays.
The document contains problem sets and questions related to sequential programming in C++. It includes questions on converting mathematical expressions to C++ expressions, evaluating expressions based on precedence, identifying valid and invalid variable names, tracing output of C++ code snippets, and writing C++ programs to solve problems related to basic calculations, data type conversions, and operations on user input values.
The documents contain program code snippets for various sorting and searching algorithms in C programming language including selection sort, bubble sort, quick sort, merge sort, insertion sort, binary search and linear search. The programs take input from the user, implement the respective algorithms to sort or search arrays of numbers, and output the results.
This document contains laboratory experiments on advanced Java programming concepts implemented using Java Server Pages (JSP) and Servlets. The experiments cover printing "Hello World", displaying system date and time, calculating factorials, addition of two numbers, simple interest calculation, solving quadratic equations, income tax calculation, and checking for prime numbers. Code snippets are provided for each experiment to accept user input, perform the given task on the server-side, and return output to the client. The directory structure and deployment details of sample JSP/Servlet programs are also included.
The document contains code for implementing various sorting algorithms in C including heapsort, quicksort, insertion sort, bubble sort, selection sort, and merge sort. For each algorithm, the code is provided to sort an integer array, take user input for the array elements, run the sorting algorithm, and output the sorted array. Sample outputs are also provided showing the input and sorted output arrays for each algorithm.
The document summarizes a student's course project presentation on creating a calendar program. The program displays a calendar for any given year, showing month names, days of the week, and dates. It allows the user to input the year to display. The presentation describes the motivation, implementation requirements, algorithms, demonstration of code, inputs, outputs, future improvements, references, and concludes with a thank you.
The document contains instructions for implementing three network algorithms in C/C++: 1) An error detecting code using CRC CCIT(16 bits), 2) A distance vector algorithm to find suitable transmission paths, and 3) A congestion control algorithm using the leaky bucket method. Sample code is provided for each algorithm to calculate checksums, routing tables, and regulate output rate based on bucket size.
The document contains programs for various data structures and algorithms concepts in C language. It includes programs for 1) array operations using menu driven program, 2) string operations like pattern matching, 3) stack operations using array implementation, 4) infix to postfix conversion, 5) evaluation of postfix expression and tower of Hanoi problem using stack, 6) circular queue operations using array, 7) linked list operations on student data, and 8) doubly linked list operations on employee data. Each section provides the full code for a menu driven program to perform various operations on the given data structure.
The document contains questions and program code snippets related to data structures and algorithms topics.
1) The first section contains a program to remove negative values from a queue using arrays as the underlying data structure.
2) The second section shows functions to implement enqueue, dequeue and display operations on a circular queue using arrays.
3) The third section contains a program to implement an ascending priority queue as a linked list.
This document provides code for a program that converts infix expressions to postfix expressions. It includes functions for pushing and popping elements in a stack, determining operator precedence, and converting an infix string to postfix by processing each character. The main function gets an infix expression from the user, calls the conversion function, and prints the infix and postfix expressions. The program supports operators like +, -, *, /, %, ^ and parentheses.
The document contains questions and program code related to C programming and data structures. Some key points:
- There are questions on sorting arrays, checking for loops in arrays, nested structures, sorting based on dates of birth, and implementing functions for book-author-shelf structures.
- Program code is provided as solutions to these questions, making use of structures, pointers, functions, and linked lists.
- One question asks to write a function to sort records in a linked list based on social security number, and code for creating, displaying, and sorting a linked list is given.
Critical buckling load geometric nonlinearity analysis of springs with rigid ...Salar Delavar Qashqai
This C program performs a geometric nonlinearity analysis of springs with rigid elements under displacement-controlled large deformations. It imports input data, performs an incremental analysis to calculate critical buckling loads, and exports output to Excel and HTML files. The analysis calculates forces, displacements, and critical pressures at each increment until the ultimate displacement is reached. Output graphs the displacement versus critical pressure relationship.
This document provides an overview of weather and climate data for beginners. It discusses accessing weather forecast data through The Weather Company API and visualizing the data in Jupyter notebooks. It also covers obtaining historical weather observations and climate model data from various sources. The document explores using weather data for applications in insurance, energy, retail, and analyzing the relationship between weather and traffic collisions.
This document contains the details of a computer science project completed by Tirthanu Ghosh of class 12A. The project contains 30 programs on different topics written in the Java programming language using BlueJ. It includes programs to generate Pascal's triangle, display numbers in words, calculate an arithmetic progression series and sum, display a calendar for a given month and year, calculate factorials and Fibonacci series using recursion, and more. The document contains the algorithms, code solutions, variable descriptions and outputs for each program. It ends with acknowledgements from Tirthanu thanking those who helped with the project.
Geometric nonlinearity analysis of springs with rigid element displacement co...Salar Delavar Qashqai
This document contains the code for analyzing the geometric and material nonlinearity of springs under displacement-controlled loading. The code imports input data on spring properties and stress-strain behavior, performs an incremental analysis to calculate the base shear and displacement at each step, and exports the results to Excel and MATLAB files. Negative or invalid input values trigger error messages. The analysis calculates the strain, stiffness, and force in each spring at each increment until the ultimate displacement is reached.
Computer Science Investigatory Project class 12thiamtheanupam
This document is a project report submitted by Anupam Anand for their computer science class. It details a project on developing software for a police station. The report includes sections on the purpose, coding, structures used, functions, and a guide Mr. P.K. Gupta who oversaw the project. It describes building a program to store, modify, display and delete criminal records from a police station database.
We have selected to write a program to create a shop billing program which will allow user to input item details such as name, price, quantity, vat etc . And allow further entry of details by user to calculate the total cost. The Last Output will be shown as a bill. You Can see your previous purchases etc.
Assignement of programming & problem solving u.s ass.(1)Syed Umair
The document contains C++ code for various programming problems and their outputs. It includes programs to:
1) Generate a pattern using nested loops; find the first 8 Fibonacci numbers; swap two numbers without a third variable; print patterns of stars.
2) Take input of numbers and find the smallest, check if a number is divisible by 10, print inverted and normal triangles.
3) Calculate an expression, find the sum of the first 6 prime numbers, take student ages and calculate average.
4) Calculate bill amount after applying 10% or 15% discount based on amount.
Nonlinear analysis of braced frame with hinge by hinge method in c programmingSalar Delavar Qashqai
This document is a C program code for nonlinear analysis of braced frames with hinge elements using the hinge method. The program imports input data, calculates the global stiffness matrix and its inverse, determines member forces and displacements through matrix operations, and outputs results to Excel files. Key steps include importing geometry, material properties, and loading, calculating element and system stiffness matrices, inverting the system matrix, determining member forces and displacements, and reporting results.
The document contains code snippets for several C programs including:
1) A program to add complex numbers by defining a structure for complex numbers and taking user input for real and imaginary parts of two numbers and printing their sum.
2) A binary search algorithm implementation to search a sorted array for a key and return its index.
3) A bubble sort algorithm implementation to sort an array of long integers in ascending order by swapping adjacent elements.
The document contains C code for multiple programs that perform various calculations and operations on arrays and numbers. The programs include:
1. Evaluating mathematical expressions by taking input values, performing calculations defined by the expressions, and outputting results.
2. Performing logical operations and comparisons on input values to determine output values based on if/else or switch statements.
3. Calculating factorials, digit sums, reversing numbers, checking for palindromes, and other numeric operations using loops.
4. Generating patterns and diagrams by iterating with for loops.
5. Performing array operations like reversing elements, calculating sums, and swapping arrays.
The document contains problem sets and questions related to sequential programming in C++. It includes questions on converting mathematical expressions to C++ expressions, evaluating expressions based on precedence, identifying valid and invalid variable names, tracing output of C++ code snippets, and writing C++ programs to solve problems related to basic calculations, data type conversions, and operations on user input values.
The documents contain program code snippets for various sorting and searching algorithms in C programming language including selection sort, bubble sort, quick sort, merge sort, insertion sort, binary search and linear search. The programs take input from the user, implement the respective algorithms to sort or search arrays of numbers, and output the results.
This document contains laboratory experiments on advanced Java programming concepts implemented using Java Server Pages (JSP) and Servlets. The experiments cover printing "Hello World", displaying system date and time, calculating factorials, addition of two numbers, simple interest calculation, solving quadratic equations, income tax calculation, and checking for prime numbers. Code snippets are provided for each experiment to accept user input, perform the given task on the server-side, and return output to the client. The directory structure and deployment details of sample JSP/Servlet programs are also included.
The document contains code for implementing various sorting algorithms in C including heapsort, quicksort, insertion sort, bubble sort, selection sort, and merge sort. For each algorithm, the code is provided to sort an integer array, take user input for the array elements, run the sorting algorithm, and output the sorted array. Sample outputs are also provided showing the input and sorted output arrays for each algorithm.
The document summarizes a student's course project presentation on creating a calendar program. The program displays a calendar for any given year, showing month names, days of the week, and dates. It allows the user to input the year to display. The presentation describes the motivation, implementation requirements, algorithms, demonstration of code, inputs, outputs, future improvements, references, and concludes with a thank you.
The basic concept for the data structure.
It covers these topics
System Life Cycle
Algorithm Specification
Data Abstraction
Performance Analysis
Space Complexity
Time Complexity
Asymptotic Notation
Text Book: Fundamentals of Data Structures in C++
E. Horowitz, et al.
This document contains C++ code that implements an adaptive Runge-Kutta Fehlberg method (RKFM) for numerically solving ordinary differential equations. It defines classes and functions for initializing the RKFM algorithm, calculating successive approximations, and checking error tolerances to adapt the step size accordingly. The main function initializes an RKFM object and calls its runIt() method to iteratively apply the algorithm up to 200 times or until the integration range is complete.
This document provides C programs to implement various data structures and algorithms. It is divided into two parts. Part A includes programs to find GCD using recursion, generate Pascal's triangle using binomial coefficients, find Fibonacci numbers recursively, implement Towers of Hanoi recursively, find the largest and smallest element in an array, write even and odd numbers to separate files, store student records in a file, and sort city names alphabetically. Part B includes programs to sort arrays using insertion, quick, merge, selection and bubble sort and perform linear and binary searches recursively. It also includes programs to implement stacks, queues, linked lists and binary trees.
talk at Virginia Bioinformatics Institute, December 5, 2013ericupnorth
Extensible domain-specific programming for the sciences
The notion of scientists as programmers begs the question of what sort of programming language would be a good fit. The common answer seems to be both none of them and all of them. Many scientific applications are a combination of general-purpose and domain-specific languages: R for statistical elements, MATLAB for matrix-based computations, Perl-based regular expressions for string matching, C or FORTRAN for high performance parallel computations, and scripting languages such as Python to glue them all together. This clumsy situation demonstrates the need for different domain-specific language features.
Our hypothesis is that programming could be made easier, less error-prone and result in higher-quality code if languages could be easily extended, by the programmer, with the domain-specific features that a programmer or scientists needs for their particular task at hand. This talk demonstrates the meta-language processing tools that support this composition of programmer-selected language features, with several extensions chosen from the previously mentioned list of features.
Computer Science Practical Science C++ with SQL commandsVishvjeet Yadav
This document contains a practical record file for programming language C++ and database SQL presented by a student. It includes 46 topics covering various C++ programs like array operations, searching and sorting algorithms, structure implementation, stack and queue implementation using arrays and linked lists. It also covers SQL topics like creating database and tables, inserting and selecting data, using where and order by clauses, updating and deleting records. Each topic is given a page number for easy reference in the index section.
The document provides source code for generating and manipulating computer graphics using various algorithms. It includes algorithms for drawing lines, circles and curves, as well as algorithms for translating, rotating, and scaling two-dimensional and three-dimensional objects. The source code is written in C/C++ and uses graphics libraries to output the results. Various input parameters are taken from the user and output is displayed to demonstrate the algorithms.
Random speed program in CPP
This program is calculating the random speed explicitly and implementing the concept of matrix.
programminghomeworkhelp.com is the leading online solution provider for C++ Programming assignments. If you are struggling with your scoring in C++ Programming Assignments, Homework or Projects then email your requirements at info@programminghomeworkhelp.com and we will ensure excellent grades. Email your C++ assignment to info@programminghomeworkhelp.com and distress yourself from the complex C++ Programming Assignments.
A scrupulous code review - 15 bugs in C++ codePVS-Studio LLC
A close look at 15 problems one can find when reviewing C++ code.
Offers code examples.
Covers indexed loops, tainted data, copy and paste errors, problems with comparisons, exceptions, etc.
You can use static code analysis tools to make code review easier. Code analyzers find errors and potential vulnerabilities in code, while saving the developers' time and the companies' money.
Manual code review is expensive - a group of programmers get together regularly to review the code.
One can run static analysis tools regularly to find mistakes and vulnerabilities early.
This document provides information on arrays in C programming. It defines an array as a collection of data storage locations with the same name and data type. It discusses array declaration, initialization, accessing elements using indexes, insertion and deletion of elements, and multi-dimensional arrays. Code examples are provided to demonstrate printing the contents of 1D, 2D and 3D arrays. The document also lists some reference books for learning C programming.
This document contains programs to simulate various CPU scheduling algorithms and memory management techniques. It includes programs for FCFS, SJF, priority, and round robin scheduling. It also includes programs to simulate MVT and MFT memory allocation algorithms, as well as FIFO and LRU page replacement algorithms. The programs take input data, perform the necessary calculations, and output scheduling or memory allocation results.
This document contains a lab manual for operating systems with programs to simulate various CPU scheduling algorithms like FCFS, SJF, Priority, and Round Robin. It also contains programs to simulate memory allocation techniques like MVT and MFT. The FCFS program takes processes as input and outputs their waiting times, start times, turnaround times and completion times. The MVT program simulates memory allocation and calculates external fragmentation. The MFT program divides memory into partitions of equal size and allocates processes to calculate internal fragmentation.
This document contains programs to simulate various CPU scheduling algorithms and memory management techniques. It includes programs for FCFS, SJF, priority, and round robin scheduling. It also includes programs to simulate MVT and MFT memory allocation algorithms, as well as FIFO and LRU page replacement algorithms. The programs take input data, perform the necessary calculations, and output scheduling or memory allocation results.
Advanced control scheme of doubly fed induction generator for wind turbine us...IJECEIAES
This paper describes a speed control device for generating electrical energy on an electricity network based on the doubly fed induction generator (DFIG) used for wind power conversion systems. At first, a double-fed induction generator model was constructed. A control law is formulated to govern the flow of energy between the stator of a DFIG and the energy network using three types of controllers: proportional integral (PI), sliding mode controller (SMC) and second order sliding mode controller (SOSMC). Their different results in terms of power reference tracking, reaction to unexpected speed fluctuations, sensitivity to perturbations, and resilience against machine parameter alterations are compared. MATLAB/Simulink was used to conduct the simulations for the preceding study. Multiple simulations have shown very satisfying results, and the investigations demonstrate the efficacy and power-enhancing capabilities of the suggested control system.
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSIJNSA Journal
The smart irrigation system represents an innovative approach to optimize water usage in agricultural and landscaping practices. The integration of cutting-edge technologies, including sensors, actuators, and data analysis, empowers this system to provide accurate monitoring and control of irrigation processes by leveraging real-time environmental conditions. The main objective of a smart irrigation system is to optimize water efficiency, minimize expenses, and foster the adoption of sustainable water management methods. This paper conducts a systematic risk assessment by exploring the key components/assets and their functionalities in the smart irrigation system. The crucial role of sensors in gathering data on soil moisture, weather patterns, and plant well-being is emphasized in this system. These sensors enable intelligent decision-making in irrigation scheduling and water distribution, leading to enhanced water efficiency and sustainable water management practices. Actuators enable automated control of irrigation devices, ensuring precise and targeted water delivery to plants. Additionally, the paper addresses the potential threat and vulnerabilities associated with smart irrigation systems. It discusses limitations of the system, such as power constraints and computational capabilities, and calculates the potential security risks. The paper suggests possible risk treatment methods for effective secure system operation. In conclusion, the paper emphasizes the significant benefits of implementing smart irrigation systems, including improved water conservation, increased crop yield, and reduced environmental impact. Additionally, based on the security analysis conducted, the paper recommends the implementation of countermeasures and security approaches to address vulnerabilities and ensure the integrity and reliability of the system. By incorporating these measures, smart irrigation technology can revolutionize water management practices in agriculture, promoting sustainability, resource efficiency, and safeguarding against potential security threats.
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...University of Maribor
Slides from talk presenting:
Aleš Zamuda: Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapter and Networking.
Presentation at IcETRAN 2024 session:
"Inter-Society Networking Panel GRSS/MTT-S/CIS
Panel Session: Promoting Connection and Cooperation"
IEEE Slovenia GRSS
IEEE Serbia and Montenegro MTT-S
IEEE Slovenia CIS
11TH INTERNATIONAL CONFERENCE ON ELECTRICAL, ELECTRONIC AND COMPUTING ENGINEERING
3-6 June 2024, Niš, Serbia
Literature Review Basics and Understanding Reference Management.pptxDr Ramhari Poudyal
Three-day training on academic research focuses on analytical tools at United Technical College, supported by the University Grant Commission, Nepal. 24-26 May 2024
Embedded machine learning-based road conditions and driving behavior monitoringIJECEIAES
Car accident rates have increased in recent years, resulting in losses in human lives, properties, and other financial costs. An embedded machine learning-based system is developed to address this critical issue. The system can monitor road conditions, detect driving patterns, and identify aggressive driving behaviors. The system is based on neural networks trained on a comprehensive dataset of driving events, driving styles, and road conditions. The system effectively detects potential risks and helps mitigate the frequency and impact of accidents. The primary goal is to ensure the safety of drivers and vehicles. Collecting data involved gathering information on three key road events: normal street and normal drive, speed bumps, circular yellow speed bumps, and three aggressive driving actions: sudden start, sudden stop, and sudden entry. The gathered data is processed and analyzed using a machine learning system designed for limited power and memory devices. The developed system resulted in 91.9% accuracy, 93.6% precision, and 92% recall. The achieved inference time on an Arduino Nano 33 BLE Sense with a 32-bit CPU running at 64 MHz is 34 ms and requires 2.6 kB peak RAM and 139.9 kB program flash memory, making it suitable for resource-constrained embedded systems.
A review on techniques and modelling methodologies used for checking electrom...nooriasukmaningtyas
The proper function of the integrated circuit (IC) in an inhibiting electromagnetic environment has always been a serious concern throughout the decades of revolution in the world of electronics, from disjunct devices to today’s integrated circuit technology, where billions of transistors are combined on a single chip. The automotive industry and smart vehicles in particular, are confronting design issues such as being prone to electromagnetic interference (EMI). Electronic control devices calculate incorrect outputs because of EMI and sensors give misleading values which can prove fatal in case of automotives. In this paper, the authors have non exhaustively tried to review research work concerned with the investigation of EMI in ICs and prediction of this EMI using various modelling methodologies and measurement setups.
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELgerogepatton
As digital technology becomes more deeply embedded in power systems, protecting the communication
networks of Smart Grids (SG) has emerged as a critical concern. Distributed Network Protocol 3 (DNP3)
represents a multi-tiered application layer protocol extensively utilized in Supervisory Control and Data
Acquisition (SCADA)-based smart grids to facilitate real-time data gathering and control functionalities.
Robust Intrusion Detection Systems (IDS) are necessary for early threat detection and mitigation because
of the interconnection of these networks, which makes them vulnerable to a variety of cyberattacks. To
solve this issue, this paper develops a hybrid Deep Learning (DL) model specifically designed for intrusion
detection in smart grids. The proposed approach is a combination of the Convolutional Neural Network
(CNN) and the Long-Short-Term Memory algorithms (LSTM). We employed a recent intrusion detection
dataset (DNP3), which focuses on unauthorized commands and Denial of Service (DoS) cyberattacks, to
train and test our model. The results of our experiments show that our CNN-LSTM method is much better
at finding smart grid intrusions than other deep learning algorithms used for classification. In addition,
our proposed approach improves accuracy, precision, recall, and F1 score, achieving a high detection
accuracy rate of 99.50%.
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
algorithm design file
1. 1
UNIVERSITY SCHOOL OF INFORMATION COMMUNICATION
AND TECHNOLOGY
LAB FILE-IT354
ALGORITHM DESIGN AND ANALYSIS
SUBMITTED TO SUBMITTED BY
ANURADHA CHUG SURAJ KUMAR
ASSISTANT PROFESSOR 03616403215
B.TECH CSE VI SEM
2. 2
INDEX
PROGRAMS PAGE NO. DATE SIGN
1. PROGRAM FOR SEARCHING. 3 21/1
2. PROGRAM FOR SORTING (ALL) 6 28/1 TO 18/2
3. PROGRAM FOR BREADTH FIRST SEARCH. 14 28/2
4. PROGRAM FOR DEPTH FIRST SEARCH. 15 28/2
5. PROGRAM FOR KRUSKAL ALGORITHM. 16 4/3
6. PROGRAM FOR PRIM’S ALGORITHM. 17 4/3
7. PROGRAM TO IMPLEMENT DIJKSTRA ALGORITHM. 20 11/3
8. PROGRAM TO IMPLEMENT FLOYAD WARSHAL ALGORITHM. 22 11/3
9. PROGRAM TO IMPLEMENT TOPLOGICAL SORT. 23 21/3
10. PROGRAM FOR MEDIAN ORDER STATISTICS. 24 21/3
11. PROGRAM FOR BELLMAN FORD ALGORITHM. 26 21/3
12. PROGRAM FOR MATRIX CHAIN MULTIPLICATION 28 2/4
13. PROGRAM FOR LONGEST COMMOM SUSEQUENCE 30 2/4
14. PROGRAM FOR HUFFMAN CODING. 32 2/4
15. PROGRAM FOR OPTIMAL BST. 35 2/4
16. STRING MATCHING USING NAÏVE ALGO 37 9/4
17. STRING MATCHING USING FINITE AUTOMATA METHOD 39 9/4
18. STRING MATCHING USING RABIN KARP ALGO 42 9/4
19. STRING MATCHING USING KMP ALGO 44 9/4
3. 3
PROGRAM FOR SEARCHING
#include<bits/stdc++.h>
using namespace std;
long int a[1000000];
vector<long int> b[100000];
void linear (long int k,long int n)
{
long int i,j;
for(i=0;i<n;i++)
{
if(a[i]==k)
cout<<"found at "<<i+1<<" position n";
}
}
long int binary(long int k,long int n)
{
long int i,j,hi=n-1,mid,lo=0,found=0;
sort(a,a+n);
mid=(hi+lo)/2;
while(found==0&&lo<=hi)
{
if(a[mid]==k)
{
found=mid+1;
break;
}
else if(k<a[mid])
{
hi=mid-1;
}
else
{
lo=mid+1;
}
mid=(lo+hi)/2;
}
return found;
}
int main()
4. 4
{
long int i,j,k,l,n,x,z=0;
clock_t start, end1;
cout<<"enter the size of arrayn";
cin>>n;
cout<<"enter the arrayn";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"select followingn";
cout<<"select 1 for linear searchn";
cout<<"selcet 2 for binary searchn";
cout<<"selcet 3 for direct searchn";
cin>>l;
if(l==1)
{
cout<<"enter the data to findn";
cin>>k;
start=clock();
linear(k,n);
}
if(l==2)
{
long int m=5;
cout<<"enter the data to findn";
cin>>k;
j=binary(k,n);
if(j==0)
cout<<"not findn";
else
cout<<"found at"<<j<<"n";
}
if(l==3)
{
for(i=0;i<n;i++)
{
x=a[i]%100000;
b[x].push_back(a[i]);
5. 5
}
cout<<"enter the number to findn";
cin>>k;
x=k%100000;
for(j=0;j<b[x].size();j++)
{
if(b[x][j]==k)
{
cout<<"found n";
z=1;
break;
}
}
if(z==0)
cout<<"not foundn";
}
end1=clock();
double time=(end1-start)/CLOCKS_PER_SEC;
cout<<time<<" sec is taken";
}
6. 6
PROGRAM FOR SORTING(ALL)
#include<bits/stdc++.h>
using namespace std;
vector< int> b1[13000];
vector< int> b2[13];
vector< int> b3[13];
int a[100000],b[10004],n=10000;
void select(int);
void bubble(int);
void insertion(int);
void mergesort(int[],int);
void merge1(int[],int[],int[],int,int);
void quick(int,int);
int partion(int,int);
void print(int);
void heapify(int [], int , int );
void heap(int []);
int main()
{
int start=0,last,start1;
char t='y';
int i,j,k,l,x,s=0,end1;
double time;
for (int i=0;i<10000;i++)
{
a[i]=rand()%1000;
}
printf("enter 1 for selection sortn");
printf("enter 2 for bubble sortn");
printf("enter 3 for insertion sortn");
printf("enter 4 for merge sortn");
printf("enter 5 for heap sortn");
printf("enter 6 for quick sortn");
cout<<"enter 7 for bucket sortn";
cout<<"enter 8 for radix sortn";
cout<<"enter 9 for counting sortn";
scanf("%d",&l);
switch(l)
{
case 1:
start1=clock();
select(n);
end1=clock();
7. 7
time=(end1-start)/CLOCKS_PER_SEC;
cout<<time<<" sec is taken";
print(n);
break;
case 2:
bubble(n);
print(n);
break;
case 3:
insertion(n);
print(n);
break;
case 4:
mergesort(a,n);
print(n);
break;
case 5:
heap(a);
print(n);
break;
case 6:
last=n-1;
quick(start,last);
print(n);
break;
}
if(l==7)
{
for(i=0;i<10000;i++)
{
x=a[i]/10;
b1[x].push_back(a[i]);
}
for(i=0;i<1000;i++)
{
sort(b1[i].begin(),b1[i].end());
}
for(i=0;i<1000;i++)
{
for(j=0;j<b1[i].size();j++)
cout<<b1[i][j]<<" ";
}
}
14. 14
PROGRAM FOR BREADTH FIRST SEAFRCH.
#include<bits/stdc++.h>
using namespace std;
vector<long int >vect[100000];
long int b[10000];
void dfs(long int k)
{
long int i,l;
stack<long int > s;
s.push(k);
while(!s.empty())
{
l=s.top();
s.pop();
if(b[l]!=1){
for(i=0;i<vect[l].size();i++)
{
s.push(vect[l][i]);
}
b[l]=1;
cout<<l<<" ";}
}
}
int main()
{
long int i,j,k,l,m,n,u,v;
cin>>m>>n;
for(i=0;i<n;i++)
{
cin>>u>>v;
vect[u].push_back(v);
vect[v].push_back(u);
}
for(i=1;i<=n;i++)
{
if(b[i]==0)
dfs(i);
}}
15. 15
PROGRAM FOR DEPTH FIRST SEARCH
#include<bits/stdc++.h>
using namespace std;
vector<long int >vect[100000];
long int b[10000];
void dfs(long int k)
{
long int i,l;
stack<long int > s;
s.push(k);
while(!s.empty())
{
l=s.top();
s.pop();
if(b[l]!=1){
for(i=0;i<vect[l].size();i++)
{
s.push(vect[l][i]);
}
b[l]=1;
cout<<l<<" ";}
}}
int main()
{
long int i,j,k,l,m,n,u,v;
cout<<"enter the number of vertices and edgesn";
cin>>m>>n;
for(i=0;i<n;i++)
{
cin>>u>>v;
vect[u].push_back(v);
vect[v].push_back(u);
}
for(i=1;i<=n;i++)
{
if(b[i]==0)
dfs(i);
}}
16. 16
PROGRAM FOR KRUSKAL ALGORITHM
#include<bits/stdc++.h>
#define MAXN 102
using namespace std;
int P[MAXN], Rank[MAXN];
int Node, edg, Cost;
struct edge { int u, v; int cost; };
edge Edge[MAXN*MAXN]; edge Path[MAXN];
int com(const void *xy, const void *xz) { edge *x = (edge*)xy; edge *y = (edge*)xz; return (x->cost - y-
>cost); }
void In() {
int i; for(i = 1; i<= Node; i++) { P[i] = i; Rank[i] = 1;
} }
int Find(int n) {
if(P[n] != n) P[n] = Find(P[n]); return P[n];
}
void Link(int x, int y)
{
if(Rank[x] > Rank[y])
{
P[y] = x;
}
else
{
P[x] = y; if(Rank[x] == Rank[y]) Rank[y]++;
}
}
void Kruscal()
{
int x, y, total = 0; Cost = 0;
for(int i = 0; i<edg; i++)
{
17. 17
x = Find(Edge[i].u);
y = Find(Edge[i].v);
if(x != y)
{
Path[total++] = Edge[i]; Link(x,y);
Cost += Edge[i].cost; if(total == Node - 1) break;
} } }
void Cal() { qsort(Edge,edg,sizeof(edge),com);
Kruscal();
cout<<"Total Cast :"<<Cost<<endl;
for(int i = 0; i<Node-1; i++)
cout<<Path[i].u<<" "<<Path[i].v<<" "<<Path[i].cost<<endl; }
int main()
{
int i;
cout<<"enter the number of verticesn";
cout<<"enter the number of edgesn";
while(cin>>Node>>edg)
{
In();
for(i = 0; i<edg; i++)
cin>>Edge[i].u>>Edge[i].v>>Edge[i].cost;
Cal();
}
}
18. 18
PROGRAM FOR PRIMS ALGORITHM
#include<bits/stdc++.h>
using namespace std;
long int a[1000][1000],b[1000],near[1000][3];
vector<long int> vect;
#define inf 10000000
int main()
{
long int i,j,k,l,m,n,u,v,c,s=inf,cost=0,co=0,pos;
cin>>n>>m;
for(i=0;i<m;i++)
{
cin>>u>>v>>c;
a[u][v]=c;
a[v][u]=c;
}
for(i=1;i<=n;i++)
{
near[i][2]=inf;
for(j=1;j<=n;j++)
{
if(a[i][j]==0)
a[i][j]=inf;
}
}
pos=1;
for(i=1;i<=n;i++)
{
if(s>a[1][i])
s=a[1][i],pos=i;
}
vect.push_back(1);
vect.push_back(pos);
cost+=s;
co++;
b[1]=-1;
b[pos]=-1;
while(co!=n-1)
{
for(i=1;i<=n;i++)
{
if(b[i]!=-1)
{
20. 20
PROGRAM TO IMPLEMENT DIJKSTRA ALGORITHM
#include<bits/stdc++.h>
using namespace std;
bitset<1000005> b;
#define pi pair<int,int>
#define pb push_back
#define mp make_pair
#define inf 100000000000009
vector<pi> edges[1000002];
long long dis[1000002],node[1000002];
void printpath(long long int n)
{
if(n!=1)
printpath(node[n]);
cout<<n<<" ";
}
void path(long long int k)
{
priority_queue<long long int> q;
q.push(k);
long long int i,l;
while(!q.empty())
{
l=q.top();
q.pop();
for(i=0;i<edges[l].size();i++)
{
if(dis[l]+edges[l][i].second<dis[edges[l][i].first])
{
dis[edges[l][i].first]=dis[l]+edges[l][i].second;
q.push(edges[l][i].first);
node[edges[l][i].first]=l;
}
}
}
}
int main()
{
long long int t,n,i,j,k,l,u,v,w;
// printf("enter the number of vertices");
21. 21
cin>>n;
// printf("enter the number of vertices");
cin>>t;
while(t--)
{
cin>>u>>v>>w;
edges[u].pb(mp(v,w));
edges[v].pb(mp(u,w));
}
for(i=2;i<=n;i++)
dis[i]=inf;
dis[1]=0;
path(1);
if(dis[n]==inf) cout<<"-1"<<endl;
else{
printpath(n);
cout<<endl;
}
}
22. 22
PROGRAM TO IMPLEMET FLOYAD WARSHAL ALGORITHM
#include<bits/stdc++.h>
using namespace std;
#define inf 100000009;
long int a[1000][1000];
int main()
{
long int i,j,k,l,m,n,u,v,w;
cout<<"enter the number of vertex";
cin>>n;
cout<<"enter the number edges";
cin>>m;
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
a[i][j]=inf;
}
for(i=1;i<=m;i++)
{
cin>>u>>v>>w;
a[u][v]=w;
a[v][u]=w;
a[i][i]=0;
}
for(k=1;k<=n;k++)
{
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
}}}
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
cout<<a[i][j]<<" ";
cout<<"n";}}
23. 23
PROGRAM FOR TOPOLOGICAL SORT
#include<bits/stdc++.h>
using namespace std;
vector<long int >vect[100000];
long int b[10000];
stack<long int> s1;
void dfs(long int k)
{
long int i,l;
b[k]=1;
for(i=0;i<vect[k].size();i++)
{
if(b[vect[k][i]]!=1)
dfs(vect[k][i]);}
s1.push(k);}
int main()
{
long int i,j,k,l,m,n,u,v;
cin>>m>>n;
for(i=0;i<n;i++)
{
cin>>u>>v;
vect[u].push_back(v);
//vect[v].push_back(u); }
for(i=1;i<=n;i++)
{
if(b[i]==0)
dfs(i); }
while(!s1.empty()){
k=s1.top();
s1.pop();
cout<<k<<" ";
}
24. 24
PROGRAM FOR MEDIN ORDER STATISTICS
#include<bits/stdc++.h>
using namespace std;
long int a[10000],l,m,n;
long int partion(long int start,long int last)
{
long int j,k,i,temp;
j=start;
k=a[last];
for(i=start;i<=last;i++)
{
if(a[i]<=k&&i!=last)
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
j++;
}
}
temp=a[j];
a[j]=a[last];
a[last]=temp;
l=j;
if(l==m-1){
return l; }
else if(m-1>l)
partion(l+1,n-1);
else
partion(0,l-1);
}
int main()
{
long int i,j=0,s,z=5;
cout<<"enter the size of arrayn";
cin>>n;
cout<<"enter the array elementsn";
for(i=0;i<n;i++)
cin>>a[i];
while(z--)
{
cout<<"enter the position to findn";
cin>>m;
26. 26
PROGRAM FOR BELLMAN FORD ALGORITHM
#include<bits/stdc++.h>
using namespace std;
# define inf 100000009
long int a[100000][5],dis[100005],dis1[100005];
int main()
{
long int i,j,k,l,m,n,u,v,w,z=0;
cout<<"enter the number of verticesn";
cin>>n;
cout<<"enter the number of edgesn";
cin>>m;
for(i=0;i<=n;i++)
dis[i]=inf;
dis[1]=0;
for(i=0;i<m;i++)
{
cin>>u>>v>>w;
a[i][0]=u;
a[i][1]=v;
a[i][2]=w;
}
for(i=1;i<=n-1;i++)
{
for(j=0;j<m;j++)
{
u=a[j][0];
v=a[j][1];
w=a[j][2];
if(dis[u]+w<dis[v])
dis[v]=dis[u]+w;
if(dis[v]+w<dis[u])
dis[u]=dis[v]+w;
}
}
for(i=1;i<=n;i++)
dis1[i]=dis[i];
for(j=0;j<m;j++)
{
u=a[j][0];
v=a[j][1];
w=a[j][2];
if(dis[u]+w<dis[v])
dis[v]=dis[u]+w;
28. 28
PROGRAM FOR MATRIX CHAIN MULTIPLICATION
#include<bits/stdc++.h>
using namespace std;
long int a[100000],b[100][100];
int main()
{
long int i,j,k,l,m,n,p,z=9999999;
cout<<"enter the NUMBER of matricen";
cin>>n;
cout<<"enter the matrices ordern";
cin>>a[0]>>a[1];
for(i=2;i<=n;i++)
{
cin>>k>>m;
a[i]=m;
}
//cin>>a[n];
for(l=2;l<=n;l++)
{
for(i=1;i<=n-l+1;i++)
{
j=i+l-1;
b[i][j]=z;
for(k=i;k<=j-1;k++)
{
p=b[i][k]+b[k+1][j]+a[i-1]*a[k]*a[j];
30. 30
PROGRAM FOR LONGEST COMMOM SUSEQUENCE
#include<bits/stdc++.h>
using namespace std;
long int i,j,k,l,m,n,l1,c[1000][1000];
int main()
{
char a[1000],b[1000];
cout<<"enter the first stringn";
cin>>a;
cout<<"enter the second stringn";
cin>>b;
l=strlen(a);
l1=strlen(b);
for(i=l-1;i>=0;i--)
a[i+1]=a[i];
for(i=l1-1;i>=0;i--)
b[i+1]=b[i];
for(i=1;i<=l;i++)
{
for(j=1;j<=l1;j++)
{
if(a[i]==b[j])
{
c[i][j]=c[i-1][j-1]+1;
35. 35
PROGRAM FOR OPTIMAL BST.
#include<bits/stdc++.h>
using namespace std;
long int c[1000][1000],f[1000],a[1000],p;
int sum(int i, int j)
{
int s = 0;
for (int k = i; k <=j; k++)
s += f[k];
return s;
}
int main()
{
long int i,j,k,l,m,n,z=999999;
cout<<"enter the size of bstn";
cin>>n;
cout<<"enter the bst elementn";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"enter the frequency of elementsn";
for(i=0;i<n;i++)
cin>>f[i];
for(i=0;i<n;i++)
c[i][i]=f[i];
for(l=2;l<=n;l++)
{
for(i=0;i<n-l+1;i++) {
39. 39
STRING MATCHING USING FINITE AUTOMATA METHOD
#include<bits/stdc++.h>
using namespace std;
long int c[1000][256];
char a[1000],b[1000];
set<char > d;
set<char>::iterator iter;
long int nextstate(long int st,long int m,char x)
{
long int nextst,i,j,l;
if (st < m && x ==b[st])
return st+1;
for (nextst = st; nextst > 0; nextst--)
{
if (b[nextst-1] == x)
{
for (i = 0; i < nextst-1; i++)
if (b[i] != b[st-nextst+1+i])
break;
if (i == nextst-1)
return nextst;
}}}
void form()
{
long int i,j,k,l,m,p,q;
m=strlen(b);
44. 44
STRING MATCHING USING KMP ALGO
#include<bits/stdc++.h>
using namespace std;
void computeLPSArray(char *pat, int M, int *lps);
void KMPSearch(char *pat, char *txt)
{
int M = strlen(pat);
int N = strlen(txt);
int lps[M];
computeLPSArray(pat, M, lps);
int i = 0;
int j = 0;
while (i < N)
{
if (pat[j] == txt[i])
{
j++;
i++;
}
45. 45
if (j == M)
{
printf("Found pattern at index %d n", i-j);
j = lps[j-1];
}
else if (i < N && pat[j] != txt[i])
{
if (j != 0)
j = lps[j-1];
else
i = i+1;
}
}
}
void computeLPSArray(char *pat, int M, int *lps)
{
int len = 0;
lps[0] = 0;
int i = 1;
while (i < M)
46. 46
{
if (pat[i] == pat[len])
{
len++;
lps[i] = len;
i++;
}
else
{
if (len != 0) {
len = lps[len-1];
}
else
{
lps[i] = 0;
i++;
}
}
}
}
int main()
{
char txt[1000],pat[1000];
47. 47
cout<<"enter the string ";
cin>>txt;
cout<<"enter the patternn";
cin>>pat;
KMPSearch(pat, txt);
return 0;
}