The document discusses the implementation of a simple queue using arrays and linked lists in C programming language. It includes functions to enqueue and dequeue elements from the queue. The main function demonstrates enqueueing multiple elements and dequeueing them. Queue is implemented using a front and rear pointer, with enqueue increasing the rear and dequeue increasing the front.
This document discusses loop parallelization and pipelining as well as trends in parallel systems and forms of parallelism. It describes loop transformations like permutation, reversal, and skewing that can be used to parallelize loops. It also discusses parallelization conditions, wavefront transformations for fine-grained parallelism, and tiling to improve data locality. The document then covers software pipelining of loops to reduce execution time. Finally, it discusses trends in parallel computing and different forms of parallelism like instruction-level, data, and task parallelism.
This document discusses linear data structures, specifically stacks and queues. It defines a stack as a linear data structure that follows the LIFO principle and can be implemented using arrays or linked lists. Queue is defined as another linear data structure that follows the FIFO principle and supports enqueue and dequeue operations. Various queue implementations like array-based queues, linked list queues, circular queues, and priority queues are described along with their operations. Common applications of stacks and queues in areas like function calls, CPU scheduling, and page replacement algorithms are also mentioned.
This document discusses different types of queues, including circular queues and priority queues. It provides examples of how circular queues resolve the memory wastage problem of linear queues by connecting the last node to the first. Priority queues are described as storing elements according to priority level, with higher priority elements processed before lower priority ones. Examples of using priority queues include theatre seating and job scheduling. The key operations and implementation using a heap data structure are also summarized.
The document discusses different types of queues and their implementations. It begins by defining a queue as a first-in first-out (FIFO) data structure where elements are inserted at the rear and deleted from the front. It then covers linear and circular queue implementations using arrays, including operations like insertion, deletion, checking for empty/full, and traversal. Priority queues are also introduced, which process elements based on assigned priorities. The key types and operations of queues as an abstract data type (ADT) are summarized.
Queue is an abstract data structure, somewhat similar to Stacks. Unlike stacks, a queue is open at both its ends. One end is always used to insert data (enqueue) and the other is used to remove data (dequeue). Queue follows First-In-First-Out methodology, i.e., the data item stored first will be accessed first.
The document discusses recursion and provides examples of recursive algorithms like factorial, Fibonacci series, and Towers of Hanoi. It explains recursion using these examples and discusses the disadvantages of recursion. It also covers divide and conquer algorithms like quicksort and binary search. Finally, it discusses backtracking and provides the example of the eight queens problem to illustrate recursive backtracking.
This document discusses stacks and queues as data structures. It begins by defining a stack as a linear collection where elements are added and removed from the top in a last-in, first-out (LIFO) manner. Common stack operations like push, pop, and peek are described. It then discusses applications of stacks like undo sequences and method calls. The document also defines queues as collections where elements are added to the rear and removed from the front in a first-in, first-out (FIFO) manner. Common queue operations and applications like waiting lists and printer access are also covered. Finally, it discusses implementations of stacks and queues using arrays and how to handle overflow and underflow cases.
This document discusses loop parallelization and pipelining as well as trends in parallel systems and forms of parallelism. It describes loop transformations like permutation, reversal, and skewing that can be used to parallelize loops. It also discusses parallelization conditions, wavefront transformations for fine-grained parallelism, and tiling to improve data locality. The document then covers software pipelining of loops to reduce execution time. Finally, it discusses trends in parallel computing and different forms of parallelism like instruction-level, data, and task parallelism.
This document discusses linear data structures, specifically stacks and queues. It defines a stack as a linear data structure that follows the LIFO principle and can be implemented using arrays or linked lists. Queue is defined as another linear data structure that follows the FIFO principle and supports enqueue and dequeue operations. Various queue implementations like array-based queues, linked list queues, circular queues, and priority queues are described along with their operations. Common applications of stacks and queues in areas like function calls, CPU scheduling, and page replacement algorithms are also mentioned.
This document discusses different types of queues, including circular queues and priority queues. It provides examples of how circular queues resolve the memory wastage problem of linear queues by connecting the last node to the first. Priority queues are described as storing elements according to priority level, with higher priority elements processed before lower priority ones. Examples of using priority queues include theatre seating and job scheduling. The key operations and implementation using a heap data structure are also summarized.
The document discusses different types of queues and their implementations. It begins by defining a queue as a first-in first-out (FIFO) data structure where elements are inserted at the rear and deleted from the front. It then covers linear and circular queue implementations using arrays, including operations like insertion, deletion, checking for empty/full, and traversal. Priority queues are also introduced, which process elements based on assigned priorities. The key types and operations of queues as an abstract data type (ADT) are summarized.
Queue is an abstract data structure, somewhat similar to Stacks. Unlike stacks, a queue is open at both its ends. One end is always used to insert data (enqueue) and the other is used to remove data (dequeue). Queue follows First-In-First-Out methodology, i.e., the data item stored first will be accessed first.
The document discusses recursion and provides examples of recursive algorithms like factorial, Fibonacci series, and Towers of Hanoi. It explains recursion using these examples and discusses the disadvantages of recursion. It also covers divide and conquer algorithms like quicksort and binary search. Finally, it discusses backtracking and provides the example of the eight queens problem to illustrate recursive backtracking.
This document discusses stacks and queues as data structures. It begins by defining a stack as a linear collection where elements are added and removed from the top in a last-in, first-out (LIFO) manner. Common stack operations like push, pop, and peek are described. It then discusses applications of stacks like undo sequences and method calls. The document also defines queues as collections where elements are added to the rear and removed from the front in a first-in, first-out (FIFO) manner. Common queue operations and applications like waiting lists and printer access are also covered. Finally, it discusses implementations of stacks and queues using arrays and how to handle overflow and underflow cases.
Computer arithmetic in computer architectureishapadhy
The document discusses Flynn's Taxonomy, which classifies computer architectures based on the number of instruction and data streams. It proposes four categories: SISD, SIMD, MISD, and MIMD. SISD refers to a single instruction single data stream architecture, like the classical von Neumann model. SIMD uses a single instruction on multiple data streams, for applications like image processing. MIMD uses multiple instruction and data streams and is most common, allowing distributed computing across independent computers. The document also discusses parallel processing, pipeline processing in computers, and hazards that can occur in instruction pipelines.
Stack and its Applications : Data Structures ADTSoumen Santra
Stacks are a data structure that follow the last-in, first-out (LIFO) principle. Elements are inserted and removed from the same end called the top of the stack. Common stack operations include push to add an element, pop to remove an element, peek to view the top element, and isEmpty to check if the stack is empty. Stacks have various applications like representing function call stacks, evaluating mathematical expressions, and solving puzzles like the Towers of Hanoi. They can be implemented using arrays or linked lists.
The document discusses queues, which are a data structure that provides first-in, first-out (FIFO) access to elements. Queues are useful for applications like print jobs and network communications where elements need to be processed in the order they are received. The key queue operations are enqueue, which inserts an element at the rear, and dequeue, which removes an element from the front. The document provides code for an IntQueue class that implements these operations using a circular array to represent the queue.
1. The document discusses stacks and queues as linear data structures. It describes stack operations like push and pop and provides algorithms for implementing these operations.
2. An example program for implementing a stack using an array is presented, with functions defined for push, pop, and display operations on the stack.
3. Applications of stacks discussed include reversing a list or string by pushing characters onto a stack and popping them off in reverse order, and converting infix expressions to postfix using a stack.
This document discusses queues and their applications. It begins by defining queues as first-in, first-out (FIFO) data structures and describes how they can be implemented using arrays or linked lists. Common applications of queues include I/O buffering, job scheduling, and round-robin threading. The document also covers double-ended queues (deques), priority queues, and their implementations and applications.
A queue is a first-in, first-out (FIFO) data structure where elements are inserted at the rear and deleted from the front. There are two common implementations - a linear array implementation where the front and rear indices are incremented as elements are added/removed, and a circular array implementation where the indices wrap around to avoid unused space. Queues have applications in printing, scheduling, and call centers where requests are handled in the order received.
This document outlines the syllabus for a course on data structures and algorithms using Java. It covers topics such as the role of algorithms and data structures, algorithm design techniques, types of data structures including primitive types, arrays, stacks, queues, linked lists, trees, graphs, and algorithm analysis. Specific algorithms and data structures discussed include sorting, searching, priority queues, stacks, queues, linked lists, trees, graphs, hashing, and complexity theory.
The document discusses queues and priority queues. It defines a queue as a waiting line that grows by adding elements to its end and shrinks by taking elements from its front. Common queue operations include enqueue, dequeue, front, clear, isEmpty. Queues follow FIFO order. Priority queues allow elements to be dequeued out of order based on priority. Array and linked list implementations of regular and priority queues are presented. Applications discussed include round robin scheduling, waiting lists, and shared resource access.
The document discusses double-ended queues (deques), which are linear data structures that allow efficient insertion and removal of elements from both ends. A deque provides the capabilities of both stacks and queues in a single structure by allowing new elements to be added and existing elements to be removed from either the front or rear. The key operations for a deque are described, including adding and removing elements from the front/rear. Example applications like browser history and undo operations in applications are given to illustrate the use of deques.
The document discusses the queue abstract data type (ADT). A queue is a first-in, first-out (FIFO) data structure where elements are added to the rear of the queue and removed from the front. Common uses of queues include printer queues, keyboard buffers, and simulation studies. The document examines two implementations of queues - using arrays, which is suitable when the maximum size is known, and linked lists, which does not have a size limit. Pseudocode is provided for common queue operations like enqueue, dequeue, checking for empty/full, and front/make empty.
This document summarizes four parallel searching algorithms: Alpha-Beta search, which prunes unpromising branches; Jamboree search, a parallelized version of Scout search; Depth-First search, which explores branches until reaching a dead end and then backtracks; and Principal Variation Splitting (PVS) search, which searches moves level-by-level in parallel. It describes their implementations and analyses PVS search performance, finding speedups of up to 4.6x with 16 processors but load balancing issues when some processors have little work.
A New Tracer for Reverse Engineering - PacSec 2010Tsukasa Oi
This document discusses a new tracer for reverse engineering based on record and replay. It aims to make reverse engineering more efficient by overcoming issues with existing instruction tracers like slow speed and large data generation. The proposed tracer is implemented as a virtual machine monitor (VMM) on x64 platforms using binary translation. By classifying elements as deterministic or nondeterministic inputs and interrupts, it can generate small trace logs and have overhead under 100% by leveraging record and replay techniques. It also discusses challenges in modeling x86 elements and implementing lazy evaluation for EFLAGS to further improve efficiency.
The document summarizes the Eyeriss architecture for accelerating convolutional neural networks. Eyeriss uses a spatial architecture with an array of processing elements connected by a mesh network. It employs various dataflow optimizations to reduce data movement and energy costs. A key optimization is exploiting data reuse by loading inputs and weights into local register files within each processing element. Eyeriss decomposes convolutions into smaller "primitives" that are processed sequentially by each PE to maximize reuse. It also pipelines computations across the PE array to improve parallelism.
The document discusses queues and their implementation and operations. It provides the names and roll numbers of group members working on a presentation about queues. It then defines a queue as a first-in first-out (FIFO) data structure where items can be inserted at one end and removed from the other. Various examples of queue applications are given. Implementation of queues using arrays is described, including tracking the front and rear indexes and how elements are added and removed. Pseudocode for queue insertion and removal algorithms is also provided.
Data structure and algorithm using javaNarayan Sau
This presentation created for people who like to go back to basics of data structure and its implementation. This presentation mostly helps B.Tech , Bsc Computer science students as well as all programmer who wants to develop software in core areas.
Basic Queue Operation in DataStructure.pptxLakshmiSamivel
This document discusses queues as a data structure. It defines a queue as a first-in, first-out (FIFO) list that allows insertions at the rear and deletions at the front. Common applications of queues include printer buffers, media players, and operating system interrupts. The time and space complexity of basic queue operations like insertion and deletion are provided. Basic queue operations like enqueue, dequeue, peek, isFull and isEmpty are also explained with pseudocode.
Queue ADT for data structure for computerabinathsabi
This document discusses queues and their implementation as an abstract data type. It defines a queue as a first-in, first-out data structure where elements are added to the back and removed from the front. Queues can be implemented using arrays or linked lists, with operations like enqueue to add an element and dequeue to remove an element. The key aspects of a queue are modeled in a Queue class, including tracking the front and rear of the queue.
Using recycled concrete aggregates (RCA) for pavements is crucial to achieving sustainability. Implementing RCA for new pavement can minimize carbon footprint, conserve natural resources, reduce harmful emissions, and lower life cycle costs. Compared to natural aggregate (NA), RCA pavement has fewer comprehensive studies and sustainability assessments.
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.
Computer arithmetic in computer architectureishapadhy
The document discusses Flynn's Taxonomy, which classifies computer architectures based on the number of instruction and data streams. It proposes four categories: SISD, SIMD, MISD, and MIMD. SISD refers to a single instruction single data stream architecture, like the classical von Neumann model. SIMD uses a single instruction on multiple data streams, for applications like image processing. MIMD uses multiple instruction and data streams and is most common, allowing distributed computing across independent computers. The document also discusses parallel processing, pipeline processing in computers, and hazards that can occur in instruction pipelines.
Stack and its Applications : Data Structures ADTSoumen Santra
Stacks are a data structure that follow the last-in, first-out (LIFO) principle. Elements are inserted and removed from the same end called the top of the stack. Common stack operations include push to add an element, pop to remove an element, peek to view the top element, and isEmpty to check if the stack is empty. Stacks have various applications like representing function call stacks, evaluating mathematical expressions, and solving puzzles like the Towers of Hanoi. They can be implemented using arrays or linked lists.
The document discusses queues, which are a data structure that provides first-in, first-out (FIFO) access to elements. Queues are useful for applications like print jobs and network communications where elements need to be processed in the order they are received. The key queue operations are enqueue, which inserts an element at the rear, and dequeue, which removes an element from the front. The document provides code for an IntQueue class that implements these operations using a circular array to represent the queue.
1. The document discusses stacks and queues as linear data structures. It describes stack operations like push and pop and provides algorithms for implementing these operations.
2. An example program for implementing a stack using an array is presented, with functions defined for push, pop, and display operations on the stack.
3. Applications of stacks discussed include reversing a list or string by pushing characters onto a stack and popping them off in reverse order, and converting infix expressions to postfix using a stack.
This document discusses queues and their applications. It begins by defining queues as first-in, first-out (FIFO) data structures and describes how they can be implemented using arrays or linked lists. Common applications of queues include I/O buffering, job scheduling, and round-robin threading. The document also covers double-ended queues (deques), priority queues, and their implementations and applications.
A queue is a first-in, first-out (FIFO) data structure where elements are inserted at the rear and deleted from the front. There are two common implementations - a linear array implementation where the front and rear indices are incremented as elements are added/removed, and a circular array implementation where the indices wrap around to avoid unused space. Queues have applications in printing, scheduling, and call centers where requests are handled in the order received.
This document outlines the syllabus for a course on data structures and algorithms using Java. It covers topics such as the role of algorithms and data structures, algorithm design techniques, types of data structures including primitive types, arrays, stacks, queues, linked lists, trees, graphs, and algorithm analysis. Specific algorithms and data structures discussed include sorting, searching, priority queues, stacks, queues, linked lists, trees, graphs, hashing, and complexity theory.
The document discusses queues and priority queues. It defines a queue as a waiting line that grows by adding elements to its end and shrinks by taking elements from its front. Common queue operations include enqueue, dequeue, front, clear, isEmpty. Queues follow FIFO order. Priority queues allow elements to be dequeued out of order based on priority. Array and linked list implementations of regular and priority queues are presented. Applications discussed include round robin scheduling, waiting lists, and shared resource access.
The document discusses double-ended queues (deques), which are linear data structures that allow efficient insertion and removal of elements from both ends. A deque provides the capabilities of both stacks and queues in a single structure by allowing new elements to be added and existing elements to be removed from either the front or rear. The key operations for a deque are described, including adding and removing elements from the front/rear. Example applications like browser history and undo operations in applications are given to illustrate the use of deques.
The document discusses the queue abstract data type (ADT). A queue is a first-in, first-out (FIFO) data structure where elements are added to the rear of the queue and removed from the front. Common uses of queues include printer queues, keyboard buffers, and simulation studies. The document examines two implementations of queues - using arrays, which is suitable when the maximum size is known, and linked lists, which does not have a size limit. Pseudocode is provided for common queue operations like enqueue, dequeue, checking for empty/full, and front/make empty.
This document summarizes four parallel searching algorithms: Alpha-Beta search, which prunes unpromising branches; Jamboree search, a parallelized version of Scout search; Depth-First search, which explores branches until reaching a dead end and then backtracks; and Principal Variation Splitting (PVS) search, which searches moves level-by-level in parallel. It describes their implementations and analyses PVS search performance, finding speedups of up to 4.6x with 16 processors but load balancing issues when some processors have little work.
A New Tracer for Reverse Engineering - PacSec 2010Tsukasa Oi
This document discusses a new tracer for reverse engineering based on record and replay. It aims to make reverse engineering more efficient by overcoming issues with existing instruction tracers like slow speed and large data generation. The proposed tracer is implemented as a virtual machine monitor (VMM) on x64 platforms using binary translation. By classifying elements as deterministic or nondeterministic inputs and interrupts, it can generate small trace logs and have overhead under 100% by leveraging record and replay techniques. It also discusses challenges in modeling x86 elements and implementing lazy evaluation for EFLAGS to further improve efficiency.
The document summarizes the Eyeriss architecture for accelerating convolutional neural networks. Eyeriss uses a spatial architecture with an array of processing elements connected by a mesh network. It employs various dataflow optimizations to reduce data movement and energy costs. A key optimization is exploiting data reuse by loading inputs and weights into local register files within each processing element. Eyeriss decomposes convolutions into smaller "primitives" that are processed sequentially by each PE to maximize reuse. It also pipelines computations across the PE array to improve parallelism.
The document discusses queues and their implementation and operations. It provides the names and roll numbers of group members working on a presentation about queues. It then defines a queue as a first-in first-out (FIFO) data structure where items can be inserted at one end and removed from the other. Various examples of queue applications are given. Implementation of queues using arrays is described, including tracking the front and rear indexes and how elements are added and removed. Pseudocode for queue insertion and removal algorithms is also provided.
Data structure and algorithm using javaNarayan Sau
This presentation created for people who like to go back to basics of data structure and its implementation. This presentation mostly helps B.Tech , Bsc Computer science students as well as all programmer who wants to develop software in core areas.
Basic Queue Operation in DataStructure.pptxLakshmiSamivel
This document discusses queues as a data structure. It defines a queue as a first-in, first-out (FIFO) list that allows insertions at the rear and deletions at the front. Common applications of queues include printer buffers, media players, and operating system interrupts. The time and space complexity of basic queue operations like insertion and deletion are provided. Basic queue operations like enqueue, dequeue, peek, isFull and isEmpty are also explained with pseudocode.
Queue ADT for data structure for computerabinathsabi
This document discusses queues and their implementation as an abstract data type. It defines a queue as a first-in, first-out data structure where elements are added to the back and removed from the front. Queues can be implemented using arrays or linked lists, with operations like enqueue to add an element and dequeue to remove an element. The key aspects of a queue are modeled in a Queue class, including tracking the front and rear of the queue.
Using recycled concrete aggregates (RCA) for pavements is crucial to achieving sustainability. Implementing RCA for new pavement can minimize carbon footprint, conserve natural resources, reduce harmful emissions, and lower life cycle costs. Compared to natural aggregate (NA), RCA pavement has fewer comprehensive studies and sustainability assessments.
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.
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%.
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.
Low power architecture of logic gates using adiabatic techniquesnooriasukmaningtyas
The growing significance of portable systems to limit power consumption in ultra-large-scale-integration chips of very high density, has recently led to rapid and inventive progresses in low-power design. The most effective technique is adiabatic logic circuit design in energy-efficient hardware. This paper presents two adiabatic approaches for the design of low power circuits, modified positive feedback adiabatic logic (modified PFAL) and the other is direct current diode based positive feedback adiabatic logic (DC-DB PFAL). Logic gates are the preliminary components in any digital circuit design. By improving the performance of basic gates, one can improvise the whole system performance. In this paper proposed circuit design of the low power architecture of OR/NOR, AND/NAND, and XOR/XNOR gates are presented using the said approaches and their results are analyzed for powerdissipation, delay, power-delay-product and rise time and compared with the other adiabatic techniques along with the conventional complementary metal oxide semiconductor (CMOS) designs reported in the literature. It has been found that the designs with DC-DB PFAL technique outperform with the percentage improvement of 65% for NOR gate and 7% for NAND gate and 34% for XNOR gate over the modified PFAL techniques at 10 MHz respectively.
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...IJECEIAES
Climate change's impact on the planet forced the United Nations and governments to promote green energies and electric transportation. The deployments of photovoltaic (PV) and electric vehicle (EV) systems gained stronger momentum due to their numerous advantages over fossil fuel types. The advantages go beyond sustainability to reach financial support and stability. The work in this paper introduces the hybrid system between PV and EV to support industrial and commercial plants. This paper covers the theoretical framework of the proposed hybrid system including the required equation to complete the cost analysis when PV and EV are present. In addition, the proposed design diagram which sets the priorities and requirements of the system is presented. The proposed approach allows setup to advance their power stability, especially during power outages. The presented information supports researchers and plant owners to complete the necessary analysis while promoting the deployment of clean energy. The result of a case study that represents a dairy milk farmer supports the theoretical works and highlights its advanced benefits to existing plants. The short return on investment of the proposed approach supports the paper's novelty approach for the sustainable electrical system. In addition, the proposed system allows for an isolated power setup without the need for a transmission line which enhances the safety of the electrical network
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTjpsjournal1
The rivalry between prominent international actors for dominance over Central Asia's hydrocarbon
reserves and the ancient silk trade route, along with China's diplomatic endeavours in the area, has been
referred to as the "New Great Game." This research centres on the power struggle, considering
geopolitical, geostrategic, and geoeconomic variables. Topics including trade, political hegemony, oil
politics, and conventional and nontraditional security are all explored and explained by the researcher.
Using Mackinder's Heartland, Spykman Rimland, and Hegemonic Stability theories, examines China's role
in Central Asia. This study adheres to the empirical epistemological method and has taken care of
objectivity. This study analyze primary and secondary research documents critically to elaborate role of
china’s geo economic outreach in central Asian countries and its future prospect. China is thriving in trade,
pipeline politics, and winning states, according to this study, thanks to important instruments like the
Shanghai Cooperation Organisation and the Belt and Road Economic Initiative. According to this study,
China is seeing significant success in commerce, pipeline politics, and gaining influence on other
governments. This success may be attributed to the effective utilisation of key tools such as the Shanghai
Cooperation Organisation and the Belt and Road Economic Initiative.
1. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
SIMPLE QUEUE
SIMPLE QUEUE
(ARRAY IMPLEMENTATION)
2. • Some computer programming languages allow a module or
function to call itself.
• This technique is known as recursion.
• In recursion, a function α either calls itself directly or calls a
function β that in turn calls the original function α. The
function α is called recursive function.
• Using recursive algorithm, certain problems can be solved
quite easily.
• Examples of such problems are Tower of Hanoi (TOH),
Inorder/Preorder/Postorder Tree Traversal, DFS of Graph etc.
1/20/2023
2
Recursion (CO4)
3. • A recursive function can go infinite like a loop. To avoid
infinite running of recursive function, there are two properties
that a recursive function must have −
– Base criteria − There must be at least one base criteria or
condition, such that, when this condition is met the function
stops calling itself recursively.
– Progressive approach − The recursive calls should progress in
such a way that each time a recursive call is made it comes
closer to the base criteria.
• Example:-
int fact(int n)
{
if (n < = 1) // base case
return 1;
else
return n*fact(n-1); }
1/20/2023
3
Properties of Recursion
4. A function fun is called direct
recursive if it calls the same
function fun.
• // An example of direct
recursion
void directRecFun()
{
// Some code....
directRecFun();
// Some code...
}
A function fun is called indirect
recursive if it calls another function
say fun_new and fun_new calls fun
directly or indirectly.
• // An example of indirect
recursion
void indirectRecFun1()
{
// Some code...
IndirectRecFun2();
// Some code...
}
void indirectRecFun2()
{
// Some code...
indirectRecFun1();
// Some code...
}
1/20/2023
4
Direct and Indirect Recursion
5. • When any function is called from main(), the memory is
allocated to it on the stack. A recursive function calls itself,
the memory for a called function is allocated on top of
memory allocated to calling function and different copy of
local variables is created for each function call. When the base
case is reached, the function returns its value to the function
by whom it is called and memory is de-allocated and the
process continues.
• Example:-
int fact(int n)
{
if (n < = 1) // base case
return 1;
else
return n*fact(n-1); }
1/20/2023
5
Recursion Working
8. • Fibonacci series
Int fib(int n)
{
if(n=0 or n=1)
return n;
else
return fib(n-1)+fib(n-
2);
}
• Power
int power(int a, int b)
{
if(b==0)
return 1;
else
return a*power(a, b-
1);
}
1/20/2023
8
More examples of recursion
9. • Advantage:-
– Recursion provides a clean and simple way to write code.
– Some problems are inherently recursive like tree
traversals, Tower of Hanoi, etc. For such problems, it is
preferred to write recursive code.
– We can write such codes also iteratively with the help of a stack
data structure.
• Disadvantage:-
– Every recursive program can be written iteratively and vice versa
is also true.
– The recursive program has greater space requirements than
iterative program as all functions will remain in the stack until
the base case is reached.
– It also has greater time requirements because of function calls
and returns overhead.
1/20/2023
9
Advantage and Disadvantage of
Recursion
10. • Tower of Hanoi, is a mathematical puzzle which consists of
three towers (pegs) and more than one rings is as depicted −
• These rings are of different sizes and stacked upon in an
ascending order, i.e. the smaller one sits over the larger one.
There are other variations of the puzzle where the number of
disks increase, but the tower count remains the same.
1/20/2023
10
Tower of Hanoi
11. • The mission is to move all the disks to some another tower
without violating the sequence of arrangement. A few rules to
be followed for Tower of Hanoi are −
– Only one disk can be moved among the towers at any
given time.
– Only the "top" disk can be removed.
– No large disk can sit over a small disk.
1/20/2023
11
Tower of Hanoi (Rules)
12. • We divide the stack of disks in two parts. The largest disk
(nth disk) is in one part and all other (n-1) disks are in the
second part.
• Our ultimate aim is to move disk n from source to destination
and then put all other (n-1) disks onto it. We can imagine to
apply the same in a recursive way for all given set of disks.
• The steps to follow are −
– Step 1 − Move n-1 disks from source to aux
– Step 2 − Move nth disk from source to dest
– Step 3 − Move n-1 disks from aux to dest
1/20/2023
12
Tower of Hanoi (Algorithm)
13. • Algorithm:-
START
Procedure Hanoi(disk, source, aux, dest)
IF disk == 1, THEN
move disk from source to dest
ELSE
Hanoi(disk - 1, source, dest, aux) // Step 1
move disk from source to dest // Step 2
Hanoi(disk - 1, aux, source, dest) // Step 3
END IF
END Procedure
STOP
1/20/2023
13
Tower of Hanoi (Algorithm)
14. 1/20/2023
14
Tower of Hanoi (Example)
• A=Beginning, B=Auxillary, C=Destination
• If n is the number of disks then 2n-1 steps are required for
solving the problem.
16. • Queue is an abstract data structure, somewhat similar to
Stacks. Unlike stacks, a queue is open at both its ends. One
end is always used to insert data (enqueue) and the other is
used to remove data (dequeue). Queue follows First-In-First-
Out methodology, i.e., the data item stored first will be
accessed first.
• A real-world example of queue can be a single-lane one-way
road, where the vehicle enters first, exits first. More real-
world examples can be seen as queues at the ticket windows
and bus-stops.
1/20/2023
16
Queues (CO1)
17. • As we now understand that in queue, we access both ends for
different reasons. The following diagram given below tries to
explain queue representation as data structure −
• As in stacks, a queue can also be implemented using Arrays,
Linked-lists
1/20/2023
17
Queue Representation
18. • A queue can be implemented by means of:-
– Array (Static Implementation)
– Linked List (Dynamic Implementation)
1/20/2023
18
Queue Implementation
19. • Queue operations may involve initializing or defining the
queue, utilizing it, and then completely erasing it from the
memory. Here we shall try to understand the basic operations
associated with queues −
– enqueue() − add (store) an item to the queue.
– dequeue() − remove (access) an item from the queue.
• In queue, we always dequeue (or access) data, pointed
by front pointer and while enqueing (or storing) data in the
queue we take help of rear pointer.
1/20/2023
19
Basic Operations
20. • Queues maintain two data pointers, front and rear.
Therefore, its operations are comparatively difficult to
implement than stacks.
• The following steps should be taken to enqueue (insert) data
into a queue
– Step 1 − Check if the queue is full.
– Step 2 − If the queue is full, produce overflow error and exit.
– Step 3 − If the queue is not full, increment rear pointer to
point the next empty space.
– Step 4 − Add data element to the queue location, where the
rear is pointing.
– Step 5 − return success.
1/20/2023
20
Enqueue Operation
21. • Implementation of enqueue() in C programming language −
• Example
int enqueue(int data)
if(isfull())
return 0;
rear = rear + 1;
queue[rear] = data;
return 1;
end procedure
1/20/2023
21
Enqueue Operation
22. • Accessing data from the queue is a process of two tasks −
access the data where front is pointing and remove the data
after access. The following steps are taken to
perform dequeue operation −
– Step 1 − Check if the queue is empty.
– Step 2 − If the queue is empty, produce underflow error and
exit.
– Step 3 − If the queue is not empty, access the data
where front is pointing.
– Step 4 − Increment front pointer to point to the next available
data element.
– Step 5 − Return success.
1/20/2023
22
Dequeue Operation
23. • Implementation of dequeue() in C programming language −
• Example
int dequeue()
{
if(isempty())
return 0;
int data = queue[front];
front = front + 1;
return data;
}
1/20/2023
23
Dequeue Operation
24. • A circular queue is an improvement over the standard queue
structure. In a standard queue, when an element is deleted,
the vacant space is not reutilized. However, in a circular
queue, vacant spaces are reutilized.
• While inserting elements, when you reach the end of an array
and you need to insert another element, you must insert that
element at the beginning (given that the first element has
been deleted and the space is vacant).
1/20/2023
24
Circular Queue
25. • The most common queue implementation is using arrays, but
it can also be implemented using lists.
• Array implementation:-
– https://www.programiz.com/dsa/circular-queue
1/20/2023
25
Circular Queue (Implementation)
27. • Dequeue or Double Ended Queue is a type of queue in which
insertion and removal of elements can be performed from
either from the front or rear.
• Thus, it does not follow FIFO rule (First In First Out).
• Types of Dequeue
– Input Restricted Deque
In this deque, input is restricted at a single end but allows
deletion at both the ends.
– Output Restricted Deque
In this deque, output is restricted at a single end but
allows insertion at both the ends.
1/20/2023
27
Dequeue
28. • Insert at the Front
• Insert at the Rear
• Delete from the Front
• Delete from the Rear
• Implementation of dequeue using array
– https://www.programiz.com/dsa/deque
1/20/2023
28
Operations on a Dequeue
29. • In undo operations on software.
• To store history in browsers.
• For implementing both stacks and queues.
1/20/2023
29
Dequeue Applications
30. • A priority queue is a special type of queue in which each
element is associated with a priority and is served according
to its priority.
• If elements with the same priority occur, they are served
according to their order in the queue.
1/20/2023
30
Priority Queue
31. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PROGRAM TO IMPLEMENT SIMPLE QUEUE USING ARRAY
#include <stdio.h>
#include <stdlib.h>
#define MAXSIZE 7
void display(int Queue[],int front,int rear)
{
int i;
if(front==-1)
{
printf("Queue is Emptyn");
return;
}
for(i=front;i<=rear;i++)
printf("%d ",Queue[i]);
printf("n");
}
32. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
FUNCTION : ENQUEUE OPERATION
void enqueue(int Queue[],int *front,int *rear,int item)
{ if(*rear==MAXSIZE-1)
{
printf("Overflown");
return;
}
if(*front==-1)
{
*front=0;
*rear=0;
}
else
*rear=*rear+1;
Queue[*rear]=item;
display(Queue,*front,*rear);
}
33. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
FUNCTION: DEQUEUE OPERATION
int dequeue(int Queue[],int *front,int *rear)
{
int x;
if(*front==-1)
{
printf("Underflown");
return -1;
}
x=Queue[*front];
if(*front==*rear)
*front=*rear=-1;
else
*front=*front+1;
display(Queue,*front,*rear);
return x;
}
34. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
MAIN() FUNCTION
int main()
{
int Queue[MAXSIZE];
int front=-1,rear=-1;
//display(Queue,front,rear);
enqueue(Queue,&front,&rear,1);
enqueue(Queue,&front,&rear,2);
enqueue(Queue,&front,&rear,3);
enqueue(Queue,&front,&rear,4);
enqueue(Queue,&front,&rear,5);
enqueue(Queue,&front,&rear,6);
enqueue(Queue,&front,&rear,7);
enqueue(Queue,&front,&rear,8);
dequeue(Queue,&front,&rear);
35. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
MAIN() FUNCTION
dequeue(Queue,&front,&rear);
dequeue(Queue,&front,&rear);
dequeue(Queue,&front,&rear);
dequeue(Queue,&front,&rear);
dequeue(Queue,&front,&rear);
dequeue(Queue,&front,&rear);
dequeue(Queue,&front,&rear);
return 0;
}
36. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
SIMPLE QUEUE
SIMPLE QUEUE
(LINKED LIST IMPLEMENTATION)
37. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PROGRAM TO IMPLEMENT SIMPLE QUEUE LINKED LIST
#include <stdio.h>
#include <stdlib.h>
#include<limits.h>
struct node
{
int data;
struct node *next;
};
struct node *Allocate(int x)
{ struct node *nn=(struct node *)malloc(sizeof(struct node));
if(nn==NULL)
return NULL;
nn->data=x;
nn->next=NULL;
return nn;
};
38. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PROGRAM TO IMPLEMENT SIMPLE QUEUE LINKED LIST
void display(struct node *fr,struct node *re)
{
struct node *t;
if(fr==NULL)
{
printf("Queue is empty");
return;
}
for(t=fr;t!=re;t=t->next)
{
printf("%d -> ",t->data);
}
printf("%d ",t->data);
}
39. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PROGRAM TO IMPLEMENT SIMPLE QUEUE LINKED LIST
void enqueue(struct node **fr,struct node **re,int x)
{
struct node *nn=Allocate(x);
if(nn==NULL)
{
printf("nOverflow");
return;
}
if(*fr==NULL)
*fr=*re=nn;
else
{
(*re)->next=nn;
*re=nn;
}
}
40. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PROGRAM TO IMPLEMENT SIMPLE QUEUE LINKED LIST
int dequeue(struct node **fr,struct node **re)
{ int x;
struct node *temp;
if(*fr==NULL)
{
printf("nUnderflow");
return INT_MIN;
}
temp=*fr;
if(*fr==*re)
*fr=*re=NULL;
else
*fr=(*fr)->next;
x=temp->data;
free(temp);
return x;
}
41. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PROGRAM TO IMPLEMENT SIMPLE QUEUE LINKED LIST
int main()
{ struct node *front=NULL,*rear=NULL;
int x;
enqueue(&front,&rear,1);
enqueue(&front,&rear,2);
enqueue(&front,&rear,3);
enqueue(&front,&rear,4);
enqueue(&front,&rear,5);
enqueue(&front,&rear,6);
enqueue(&front,&rear,7);
enqueue(&front,&rear,8);
display(front,rear);
x=dequeue(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
42. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PROGRAM TO IMPLEMENT SIMPLE QUEUE LINKED LIST
x=dequeue(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
43. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PROGRAM TO IMPLEMENT SIMPLE QUEUE LINKED LIST
x=dequeue(&front, &rear);
if(x!=INT_MIN)
printf("n%d is deleted", x);
x=dequeue(&front, &rear);
if(x!=INT_MIN)
printf("n%d is deleted", x);
x=dequeue(&front, &rear);
if(x!=INT_MIN)
printf("n%d is deleted", x);
return 0;
}
44. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
CIRCULAR QUEUE
CIRCULAR QUEUE
(ARRAY IMPLEMENTATION)
45. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PROGRAM TO IMPLEMENT CIRCULAR QUEUE USING ARRAY
#include <stdio.h>
#include <stdlib.h>
#include<limits.h>
#define MAXSIZE 20
void display(int *Queue,int front, int rear)
{
int i;
if(front==-1)
{
printf("Queue is emptyn");
return;
}
for(i=front;i!=rear;i=(i+1)%MAXSIZE)
{
printf("%d ",Queue[i]);
}
printf("%d",Queue[i]);
}
46. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PROGRAM TO IMPLEMENT CIRCULAR QUEUE USING ARRAY
void enqueue(int *Queue,int *front, int *rear,int x)
{
if(*front == (*rear+1)%MAXSIZE){
printf("Overflown");
return;
}
if(*front==-1)
*front=*rear=0;
else
*rear=(*rear+1)%MAXSIZE;
Queue[*rear]=x;
}
47. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PROGRAM TO IMPLEMENT CIRCULAR QUEUE USING ARRAY
int dequeue(int *Queue,int *front,int *rear)
{
int x;
if(*front==-1)
{
printf("Underflown");
return INT_MIN;
}
x=Queue[*front];
if(*front==*rear)
*front=*rear=-1;
else
*front=(*front+1)%MAXSIZE;
return x;
}
48. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PROGRAM TO IMPLEMENT CIRCULAR QUEUE USING ARRAY
int main()
{
int Queue[MAXSIZE];
int front=-1,rear=-1,x;
enqueue(Queue,&front,&rear,1);
enqueue(Queue,&front,&rear,2);
enqueue(Queue,&front,&rear,3);
enqueue(Queue,&front,&rear,4);
enqueue(Queue,&front,&rear,5);
display(Queue,front,rear);
x=dequeue(Queue,&front,&rear);
if(x!=INT_MIN)
printf("n%d is deletedn",x);
49. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PROGRAM TO IMPLEMENT CIRCULAR QUEUE USING ARRAY
x=dequeue(Queue,&front,&rear);
if(x!=INT_MIN)
printf("%d is deletedn",x);
x=dequeue(Queue,&front,&rear);
if(x!=INT_MIN)
printf("%d is deletedn",x);
x=dequeue(Queue,&front,&rear);
if(x!=INT_MIN)
printf("%d is deletedn",x);
x=dequeue(Queue,&front,&rear);
if(x!=INT_MIN)
printf("%d is deletedn",x);
x=dequeue(Queue,&front,&rear);
if(x!=INT_MIN)
printf("%d is deletedn",x);
return 0;
}
50. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
CIRCULAR QUEUE
CIRCULAR QUEUE
LINKED LIST IMPLEMENTATION
51. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PROGRAM TO IMPLEMENT CIRCULAR QUEUE LINKED LIST
#include <stdio.h>
#include <stdlib.h>
#include<limits.h>
struct node
{
int data;
struct node *next;
};
struct node *Allocate(int x)
{
struct node *nn=(struct node *)malloc(sizeof(struct node));
if(nn==NULL)
return NULL;
nn->data=x;
nn->next=NULL;
return nn;
};
52. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PROGRAM TO IMPLEMENT CIRCULAR QUEUE LINKED LIST
void display(struct node *fr,struct node *re)
{
struct node *t;
if(fr==NULL)
{
printf("Queue is empty");
return;
}
for(t=fr;t!=re;t=t->next)
{
printf("%d -> ",t->data);
}
printf("%d ",t->data);
}
53. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PROGRAM TO IMPLEMENT CIRCULAR QUEUE LINKED LIST
void enqueue(struct node **fr,struct node **re,int x)
{
struct node *nn=Allocate(x);
if(nn==NULL)
{
printf("nOverflow");
return;
}
if(*fr==NULL)
{
nn->next=nn;
*fr=*re=nn;
}
else
{
nn->next=*fr;
(*re)->next=nn;
*re=nn;
}
}
54. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PROGRAM TO IMPLEMENT CIRCULAR QUEUE LINKED LIST
int dequeue(struct node **fr,struct node **re)
{ int x;
struct node *temp;
if(*fr==NULL)
{
printf("nUnderflow");
return INT_MIN;
}
temp=*fr;
if(*fr==*re)
*fr=*re=NULL;
else
{
*fr=(*fr)->next;
(*re)->next=*fr;
}
x=temp->data;
free(temp);
return x;
}
55. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PROGRAM TO IMPLEMENT CIRCULAR QUEUE LINKED LIST
int main()
{ struct node *front=NULL,*rear=NULL;
int x;
enqueue(&front,&rear,1);
enqueue(&front,&rear,2);
enqueue(&front,&rear,3);
enqueue(&front,&rear,4);
enqueue(&front,&rear,5);
enqueue(&front,&rear,6);
enqueue(&front,&rear,7);
enqueue(&front,&rear,8);
display(front,rear);
x=dequeue(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
56. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PROGRAM TO IMPLEMENT CIRCULAR QUEUE LINKED LIST
x=dequeue(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
57. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PROGRAM TO IMPLEMENT CIRCULAR QUEUE LINKED LIST
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
return 0;
}
58. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PRIORITY QUEUE
PRIORITY QUEUE
(ARRAY IMPLEMENTATION)
59. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PRIORITY QUEUE
#include <stdio.h>
#include <stdlib.h>
#include<limits.h>
#define MAXPR 5
#define MAXSIZE 5
int Q[MAXPR][MAXSIZE];
int front[MAXPR];
int rear[MAXPR];
60. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PRIORITY QUEUE
void display()
{ int i,j;
for(i=0;i<MAXPR;i++)
{
for(j=0;j<MAXSIZE;j++)
{
if(Q[i][j]==INT_MIN)
printf(" ");
else
printf("%-2d ",Q[i][j]);
}
printf("Front[%d] = %2d, ",i,front[i]);
printf("Rear[%d] = %2d ",i,rear[i]);
printf("n");
}
}
61. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PRIORITY QUEUE: ENQUEUE
void enqueue(int val,int prn)
{
if(prn<0 || prn>=MAXPR)
return;
if(rear[prn]==MAXSIZE-1)
{
printf("Overflow");
return;
}
if(front[prn]==-1)
{
front[prn]++;
}
rear[prn]++;
Q[prn][rear[prn]]=val;
}
62. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PRIORITY QUEUE: DEQUEUE
int dequeue()
{ int i,x;
i=0;
while(i<MAXPR && front[i]==-1)
i++;
if(i==MAXPR)
{
printf("nUnderflow");
return INT_MIN;
}
x=Q[i][front[i]];
Q[i][front[i]]=INT_MIN;
if(front[i]==rear[i]){
front[i]=-1;rear[i]=-1;
}
else
front[i]++;
return x;
}
63. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PRIORITY QUEUE: MAIN()
int main()
{
int i,j,x;
for(i=0;i<MAXPR;i++)
{
front[i]=-1;
rear[i]=-1;
for(j=0;j<MAXSIZE;j++)
Q[i][j]=INT_MIN;
}
enqueue(5,1);
enqueue(6,2);
enqueue(7,1);
enqueue(28,4);
enqueue(5,2);
enqueue(3,2);
enqueue(23,0);
display();
64. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PRIORITY QUEUE: MAIN()
x=dequeue();
printf("nn%d is deletednn",x);
display();
return 0;
}
65. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PRIORITY QUEUE
PRIORITY QUEUE
LINKED LIST IMPLEMENTATION
66. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PRIORITY QUEUE
#include <stdio.h>
#include <stdlib.h>
#include<limits.h>
struct node
{
int data;
int prn;
struct node *next;
};
struct node *Allocate(int val,int p)
{
struct node *nn=(struct node*)malloc(sizeof(struct node));
if(nn!=NULL)
{
nn->data=val;
nn->prn=p;
nn->next=NULL;
}
return nn;
};
67. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PRIORITY QUEUE
void display(struct node *he)
{
struct node *cur;
if(he==NULL)
{
printf("Queue is empty");
return ;
}
for(cur=he;cur->next!=NULL;cur=cur->next)
{
printf("(%d,%d)-> ",cur->data,cur->prn);
}
printf("(%d,%d)",cur->data,cur->prn);
}
68. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PRIORITY QUEUE
void enqueue(struct node **he,int val,int p)
{
struct node *save,*cur;
struct node *nn=Allocate(val,p);
if(nn==NULL)
{
printf("Overflown");
return;
}
if(*he==NULL || p<(*he)->prn)
{
nn->next=*he;
*he=nn;
return;
}
69. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PRIORITY QUEUE
cur=*he;
while(cur!=NULL && p>=cur->prn)
{
save=cur;
cur=cur->next;
}
save->next=nn;
nn->next=cur;
}
70. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PRIORITY QUEUE
int dequeue(struct node **he)
{
struct node *temp;
int x;
if(*he==NULL)
{
printf("nUnderflown");
return INT_MIN;
}
temp=*he;
*he=(*he)->next;
x=temp->data;
free(temp);
return x;
}
71. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PRIORITY QUEUE
int main()
{
struct node *head= NULL;
int x;
enqueue(&head,15,4);
enqueue(&head,8,2);
enqueue(&head,6,7);
enqueue(&head,15,1);
enqueue(&head,19,5);
enqueue(&head,23,2);
display(head);
x=dequeue(&head);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue(&head);
if(x!=INT_MIN)
printf("n%d is deleted",x);
72. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
PRIORITY QUEUE
x=dequeue(&head);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue(&head);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue(&head);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue(&head);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue(&head);
if(x!=INT_MIN)
printf("n%d is deleted",x);
return 0;
}
73. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
DEQUE
DOUBLE ENDED QUEUE
(DEQUE)
LINKED LIST IMPLEMENTATION
(SIMPLE INPUT RESTRICTED DEQUE)
74. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
INPUT RESTRICTED DEQUE
#include <stdio.h>
#include <stdlib.h>
#include<limits.h>
struct node
{
int data;
struct node *next;
};
struct node *Allocate(int x)
{
struct node *nn=(struct node *)malloc(sizeof(struct node));
if(nn==NULL)
return NULL;
nn->data=x;
nn->next=NULL;
return nn;
};
75. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
INPUT RESTRICTED DEQUE
void display(struct node *fr,struct node *re)
{
struct node *t;
if(fr==NULL)
{
printf("Queue is empty");
return;
}
for(t=fr;t!=re;t=t->next)
{
printf("%d -> ",t->data);
}
printf("%d ",t->data);
}
77. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
INPUT RESTRICTED DEQUE
int dequeue_front(struct node **fr,struct node **re)
{
int x;
struct node *temp;
if(*fr==NULL)
{
printf("nUnderflow");
return INT_MIN;
}
temp=*fr;
if(*fr==*re)
*fr=*re=NULL;
else
*fr=(*fr)->next;
x=temp->data;
free(temp);
return x;
}
78. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
INPUT RESTRICTED DEQUE
int dequeue_rear(struct node **fr,struct node **re)
{ int x;
struct node *temp,*save,*cur;
if(*fr==NULL)
{
printf("nUnderflow");
return INT_MIN;
}
temp=*re;
if(*fr==*re)
*fr=*re=NULL;
else
{
cur=*fr;
while(cur!=*re)
{
save=cur;
cur=cur->next;
}
79. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
INPUT RESTRICTED DEQUE
save->next=NULL;
re=save;
}
x=temp->data;
free(temp);
return x;
}
80. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
INPUT RESTRICTED DEQUE
int main()
{ int x;
struct node *front=NULL,*rear=NULL;
enqueue_rear(&front,&rear,1);
enqueue_rear(&front,&rear,2);
display(front, rear);
x=dequeue_front(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue_rear(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue_front(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
return 0;
}
81. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
DEQUE
DOUBLE ENDED QUEUE
(DEQUE)
LINKED LIST IMPLEMENTATION
(SIMPLE OUTPUT RESTRICTED DEQUE)
82. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
OUPUT RESTRICTED DEQUE
#include <stdio.h>
#include <stdlib.h>
#include<limits.h>
struct node
{
int data;
struct node *next;
};
struct node *Allocate(int x)
{
struct node *nn=(struct node *)malloc(sizeof(struct node));
if(nn==NULL)
return NULL;
nn->data=x;
nn->next=NULL;
return nn;
};
83. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
OUPUT RESTRICTED DEQUE
void display(struct node *fr,struct node *re)
{
struct node *t;
if(fr==NULL)
{
printf("Queue is empty");
return;
}
for(t=fr;t!=re;t=t->next)
{
printf("%d -> ",t->data);
}
printf("%d ",t->data);
}
86. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
OUPUT RESTRICTED DEQUE
int dequeue_front(struct node **fr,struct node **re)
{
int x;
struct node *temp;
if(*fr==NULL)
{
printf("nUnderflow");
return INT_MIN;
}
temp=*fr;
if(*fr==*re)
*fr=*re=NULL;
else
*fr=(*fr)->next;
x=temp->data;
free(temp);
return x;
}
87. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
OUPUT RESTRICTED DEQUE
int main()
{ int x;
struct node *front=NULL,*rear=NULL;
enqueue_rear(&front,&rear,1);
enqueue_front(&front,&rear,2);
display(front, rear);
x=dequeue_front(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue_front(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue_front(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
return 0;
}
88. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
DEQUE
DOUBLE ENDED QUEUE
(DEQUE)
LINKED LIST IMPLEMENTATION
(CIRCULAR INPUT RESTRICTED DEQUE)
89. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
INPUT RESTRICTED DEQUE
#include <stdio.h>
#include <stdlib.h>
#include<limits.h>
struct node
{
int data;
struct node *next;
};
struct node *Allocate(int x)
{
struct node *nn=(struct node *)malloc(sizeof(struct node));
if(nn==NULL)
return NULL;
nn->data=x;
nn->next=NULL;
return nn;
};
90. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
INPUT RESTRICTED DEQUE
void display(struct node *fr,struct node *re)
{
struct node *t;
if(fr==NULL)
{
printf("Queue is empty");
return;
}
for(t=fr;t!=re;t=t->next)
{
printf("%d -> ",t->data);
}
printf("%d ",t->data);
}
92. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
INPUT RESTRICTED DEQUE
int dequeue_front(struct node **fr,struct node **re)
{ int x;
struct node *temp;
if(*fr==NULL)
{
printf("nUnderflow");
return INT_MIN;
}
temp=*fr;
if(*fr==*re)
*fr=*re=NULL;
else
{
*fr=(*fr)->next;
(*re)->next=*fr;
}
x=temp->data;
free(temp);
return x;
}
93. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
INPUT RESTRICTED DEQUE
int dequeue_rear(struct node **fr,struct node **re)
{ int x;
struct node *cur,*save;
if(*re==NULL)
{
printf("nUnderflow");
return INT_MIN;
}
cur=*fr;
if(*fr==*re)
*fr=*re=NULL;
else
{
cur=*fr;
while(cur!=*re)
{
save=cur;
cur=cur->next;
}
94. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
INPUT RESTRICTED DEQUE
save->next=*fr;
*re=save;
}
x=cur->data;
free(cur);
return x;
}
95. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
INPUT RESTRICTED DEQUE
int main()
{
struct node *front=NULL,*rear=NULL;
int x;
enqueue_rear(&front,&rear,1);
enqueue_rear(&front,&rear,2);
enqueue_rear(&front,&rear,3);
enqueue_rear(&front,&rear,4);
enqueue_rear(&front,&rear,5);
enqueue_rear(&front,&rear,6);
display(front,rear);
x=dequeue_rear(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue_front(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
96. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
INPUT RESTRICTED DEQUE
x=dequeue_rear(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue_front(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue_rear(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue_front(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue_rear(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
return 0;
}
97. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
DEQUE
DOUBLE ENDED QUEUE
(DEQUE)
LINKED LIST IMPLEMENTATION
(CIRCULAR OUTPUT RESTRICTED DEQUE)
98. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
OUTPUT RESTRICTED DEQUE
#include <stdio.h>
#include <stdlib.h>
#include<limits.h>
struct node
{
int data;
struct node *next;
};
struct node *Allocate(int x)
{
struct node *nn=(struct node *)malloc(sizeof(struct node));
if(nn==NULL)
return NULL;
nn->data=x;
nn->next=NULL;
return nn;
};
99. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
OUTPUT RESTRICTED DEQUE
void display(struct node *fr,struct node *re)
{
struct node *t;
if(fr==NULL)
{
printf("Queue is empty");
return;
}
for(t=fr;t!=re;t=t->next)
{
printf("%d -> ",t->data);
}
printf("%d ",t->data);
}
102. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
OUPUT RESTRICTED DEQUE
int dequeue_front(struct node **fr,struct node **re)
{ int x;
struct node *temp;
if(*fr==NULL)
{
printf("nUnderflow");
return INT_MIN;
}
temp=*fr;
if(*fr==*re)
*fr=*re=NULL;
else
{
*fr=(*fr)->next;
(*re)->next=*fr;
}
x=temp->data;
free(temp);
return x;
}
103. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
OUPUT RESTRICTED DEQUE
int dequeue_rear(struct node **fr,struct node **re)
{ int x;
struct node *cur,*save;
if(*re==NULL)
{
printf("nUnderflow");
return INT_MIN;
}
cur=*fr;
if(*fr==*re)
*fr=*re=NULL;
else
{
cur=*fr;
while(cur!=*re)
{
save=cur;
cur=cur->next;
}
104. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
OUPUT RESTRICTED DEQUE
save->next=*fr;
*re=save;
}
x=cur->data;
free(cur);
return x;
}
105. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
OUPUT RESTRICTED DEQUE
int main()
{
struct node *front=NULL,*rear=NULL;
int x;
enqueue_rear(&front,&rear,1);
enqueue_rear(&front,&rear,2);
enqueue_rear(&front,&rear,3);
enqueue_rear(&front,&rear,4);
enqueue_rear(&front,&rear,5);
enqueue_rear(&front,&rear,6);
display(front,rear);
x=dequeue_front(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue_front(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
106. NAGESH SHARMA, A.P. Department of CSE (AI), KIET Group of Institutions
OUPUT RESTRICTED DEQUE
x=dequeue_front(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue_front(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue_front(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue_front(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
x=dequeue_front(&front,&rear);
if(x!=INT_MIN)
printf("n%d is deleted",x);
return 0;
}