The document discusses double and circular linked lists. It covers inserting and deleting nodes from doubly linked lists and circular linked lists. Specifically, it describes how to insert nodes at different positions in a doubly linked list, such as at the front, after a given node, at the end, and before a given node. It also explains how to delete nodes from a doubly linked list. For circular linked lists, it outlines how to insert nodes in an empty list, at the beginning, at the end, and between nodes. It also provides the steps to delete nodes from a circular linked list.
a. Concept and Definition✓
b. Inserting and Deleting nodes ✓
c. Linked implementation of a stack (PUSH/POP) ✓
d. Linked implementation of a queue (Insert/Remove) ✓
e. Circular List
• Stack as a circular list (PUSH/POP) ✓
• Queue as a circular list (Insert/Remove) ✓
f. Doubly Linked List (Insert/Remove) ✓
For more course related material:
https://github.com/ashim888/dataStructureAndAlgorithm/
Personal blog
www.ashimlamichhane.com.np
Linked list
Advantages and disadvantages
Types of linked lists
Singly linked list
Doubly linked list
Header linked lists
Applications of linked list
Algorithm to search a value
Example of LinkedList
Algorithm for inserting a node
single link list
Applications of Arrays
data in continuous memory
queues
stacks
beginning of a linked list
traversing a linked list
Algorithm for traversing
Grounded header linked list
Circular Header linked list
Linked Lists: Introduction Linked lists
Representation of linked list
operations on linked list
Comparison of Linked Lists with Arrays and Dynamic Arrays
Types of Linked Lists and operations-Circular Single Linked List, Double Linked List, Circular Double Linked List
a. Concept and Definition✓
b. Inserting and Deleting nodes ✓
c. Linked implementation of a stack (PUSH/POP) ✓
d. Linked implementation of a queue (Insert/Remove) ✓
e. Circular List
• Stack as a circular list (PUSH/POP) ✓
• Queue as a circular list (Insert/Remove) ✓
f. Doubly Linked List (Insert/Remove) ✓
For more course related material:
https://github.com/ashim888/dataStructureAndAlgorithm/
Personal blog
www.ashimlamichhane.com.np
Linked list
Advantages and disadvantages
Types of linked lists
Singly linked list
Doubly linked list
Header linked lists
Applications of linked list
Algorithm to search a value
Example of LinkedList
Algorithm for inserting a node
single link list
Applications of Arrays
data in continuous memory
queues
stacks
beginning of a linked list
traversing a linked list
Algorithm for traversing
Grounded header linked list
Circular Header linked list
Linked Lists: Introduction Linked lists
Representation of linked list
operations on linked list
Comparison of Linked Lists with Arrays and Dynamic Arrays
Types of Linked Lists and operations-Circular Single Linked List, Double Linked List, Circular Double Linked List
A tree is a nonlinear data structure, compared to arrays, linked lists, stacks and queues which are linear data structures. A tree can be empty with no nodes or a tree is a structure consisting of one node called the root and zero or one or more sub-trees.
↓↓↓↓ Read More:
@ Kindly Follow my Instagram Page to discuss about your mental health problems-
-----> https://instagram.com/mentality_streak?utm_medium=copy_link
@ Appreciate my work:
-----> behance.net/burhanahmed1
Thank-you !
In computer science, a linked list is a linear collection of data elements, whose order is not given by their physical placement in memory. Instead, each element points to the next. It is a data structure consisting of a collection of nodes which together represent a sequence.
1) Introduction to Trees.
2) Basic terminologies
3) Binary tree
4) Binary tree types
5) Binary tree representation
6) Binary search tree
7) Creation of a binary tree
8) Operations on binary search tree Trees
A tree is a nonlinear data structure, compared to arrays, linked lists, stacks and queues which are linear data structures. A tree can be empty with no nodes or a tree is a structure consisting of one node called the root and zero or one or more sub-trees.
↓↓↓↓ Read More:
@ Kindly Follow my Instagram Page to discuss about your mental health problems-
-----> https://instagram.com/mentality_streak?utm_medium=copy_link
@ Appreciate my work:
-----> behance.net/burhanahmed1
Thank-you !
In computer science, a linked list is a linear collection of data elements, whose order is not given by their physical placement in memory. Instead, each element points to the next. It is a data structure consisting of a collection of nodes which together represent a sequence.
1) Introduction to Trees.
2) Basic terminologies
3) Binary tree
4) Binary tree types
5) Binary tree representation
6) Binary search tree
7) Creation of a binary tree
8) Operations on binary search tree Trees
ccvcvbcbvcbvcbvcbvcb vngfg hgjhg gj jgjhgjhgjhg jhgh jhgjhgj gjhgjhgjhgjhgjhgjhgjhg jghgjhgjhgjhgjhg jjghjhgjhgjhgjhgjh hgjhgjhgjhgjhgjhgjhgjgjhgjhgjhg hgfgfhdfhtftfj jgyjyyyugyugyug yjgghgjhgjhf drdfhgfgfgfgj jgjhgjhgjhgjhgjhg jhgghjfgf fxdx gfd hdhfd tftyf yytfy ytftyf ytf ytfty fytftykgh kghjg jhghgh fgfghfgh fgfghfgf gfgfgfgfytf hgfggf ghfgfg gjhghjg cfffgh jgfgfhgffhg hghh yuy ygyyuyutyutyu jgfghfhgfghfh fghfhgfhgf fthfhfhf hfhfhgf hfhgfghf fghfghfghfhhgfghf jgjhgjhgjhgjhgjhgj jgjhgjh jgjhg jgjhgjhgjhg jhgjhgjhg jhgjhg jhgjhgollowing the announcement of Google+ API deprecation scheduled for March 2019, a number of changes will be made to Blogger’s Google+ integration on 4 February 2019. *Google+ widgets:* Support for the “+1 Button”, “Google+ Followers” and “Google+ Badge” widgets in Layout will no longer be available. All instances of these widgets will be removed from all blogs. *+1 buttons:* The +1/G+ buttons and Google+ share links below blog posts and in the navigation bar will be removed. Please note that if you have a custom template that includes Google+ features, you may need to update ... read more ollowing the announcement of Google+ API deprecation scheduled for March 2019, a number of changes will be made to Blogger’s Google+ integration on 4 February 2019. *Google+ widgets:* Support for the “+1 Button”, “Google+ Followers” and “Google+ Badge” widgets in Layout will no longer be available. All instances of these widgets will be removed from all blogs. *+1 buttons:* The +1/G+ buttons and Google+ share links below blog posts and in the navigation bar will be removed. Please note that if you have a custom template that includes Google+ features, you may need to update ... read moreollowing the announcement of Google+ API deprecation scheduled for March 2019, a number of changes will be made to Blogger’s Google+ integration on 4 February 2019. *Google+ widgets:* Support for the “+1 Button”, “Google+ Followers” and “Google+ Badge” widgets in Layout will no longer be available. All instances of these widgets will be removed from all blogs. *+1 buttons:* The +1/G+ buttons and Google+ share links below blog posts and in the navigation bar will be removed. Please note that if you have a custom template that includes Google+ features, you may need to update ... read moreollowing the announcement of Google+ API deprecation scheduled for March 2019, a number of changes will be made to Blogger’s Google+ integration on 4 February 2019. *Google+ widgets:* Support for the “+1 Button”, “Google+ Followers” and “Google+ Badge” widgets in Layout will no longer be available. All instances of these widgets will be removed from all blogs. *+1 buttons:* The +1/G+ buttons and Google+ share links below blog posts and in the navigation bar will be removed. Please note that if you have a custom template that includes Google+ features, you may need to update ... read moreollowing the announcement of Google+ API deprecation scheduled for March 2019, a nu
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
Feature selection is the process of selecting a subset of the terms occurring in the training set and using only this subset as features in text classification.
Wi-Fi stands for Wireless Fidelity. Fidelity: A faithful output.
Generally used to connect devices in wireless mode.
It is a term that refers to IEEE 802.11 communications
Li-Fi stands for Light Fidelity.
Uses light instead of radio waves.
Uses Visible part of electromagnetic spectrum.
Also known as Light based Wi-Fi.
Communication channels through which news entertainment, education, data, or promotional messages are delivered is known as media. Media includes every broadcasting and narrow-casting medium such as Newspaper, Magazines, Television, Radio, Billboards, Direct mail, Telephone, Fax and Internet.
AGILE TESTING is a testing practice that follows the rules and principles of agile software development. Unlike the Waterfall method, Agile Testing can begin at the start of the project with continuous integration between development and testing. Agile Testing is not sequential but continuous. Agile testing involves testing as early as possible in the software development life-cycle.
Ethical hacking also known as penetration testing or white-hat hacking, involves the same tools, tricks, and techniques that hackers use, but with one major difference that Ethical hacking is legal. It focuses on authorised attempts to gain unauthorised access to systems and find vulnerabilities. Ethical hacking is done with the legal permission of a company to test and increase the security of its systems and networks.
In software engineering and software architecture design, design decisions address architecturally significant requirements; they are perceived as hard to make and/or costly to change. It is called also architecture strategies and tactics.
An algorithm is a plan, a logical step-by-step process for solving a problem. Algorithms are normally written as a flowchart or in pseudo-code.
A flowchart is a diagram that represents a set of instructions. Flowcharts normally use standard symbols to represent the different types of instructions. These symbols are used to construct the flowchart and show the step-by-step solution to the problem.
Software Quality Assurance is a means and practice of monitoring the software engineering processes and methodologies used in a project to ensure proper quality of the software. Scrum is a framework utilising an agile mindset for developing, delivering, and sustaining products in a complex environment.
This presentation defines the asteroids and describes its role in our solar system and how to protect our earth from these space rocks in case of any mishap.
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Globus
Large Language Models (LLMs) are currently the center of attention in the tech world, particularly for their potential to advance research. In this presentation, we'll explore a straightforward and effective method for quickly initiating inference runs on supercomputers using the vLLM tool with Globus Compute, specifically on the Polaris system at ALCF. We'll begin by briefly discussing the popularity and applications of LLMs in various fields. Following this, we will introduce the vLLM tool, and explain how it integrates with Globus Compute to efficiently manage LLM operations on Polaris. Attendees will learn the practical aspects of setting up and remotely triggering LLMs from local machines, focusing on ease of use and efficiency. This talk is ideal for researchers and practitioners looking to leverage the power of LLMs in their work, offering a clear guide to harnessing supercomputing resources for quick and effective LLM inference.
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar
The European Union Agency for Law Enforcement Cooperation (Europol) has suffered an alleged data breach after a notorious threat actor claimed to have exfiltrated data from its systems. Infamous data leaker IntelBroker posted on the even more infamous BreachForums hacking forum, saying that Europol suffered a data breach this month.
The alleged breach affected Europol agencies CCSE, EC3, Europol Platform for Experts, Law Enforcement Forum, and SIRIUS. Infiltration of these entities can disrupt ongoing investigations and compromise sensitive intelligence shared among international law enforcement agencies.
However, this is neither the first nor the last activity of IntekBroker. We have compiled for you what happened in the last few days. To track such hacker activities on dark web sources like hacker forums, private Telegram channels, and other hidden platforms where cyber threats often originate, you can check SOCRadar’s Dark Web News.
Stay Informed on Threat Actors’ Activity on the Dark Web with SOCRadar!
Large Language Models and the End of ProgrammingMatt Welsh
Talk by Matt Welsh at Craft Conference 2024 on the impact that Large Language Models will have on the future of software development. In this talk, I discuss the ways in which LLMs will impact the software industry, from replacing human software developers with AI, to replacing conventional software with models that perform reasoning, computation, and problem-solving.
First Steps with Globus Compute Multi-User EndpointsGlobus
In this presentation we will share our experiences around getting started with the Globus Compute multi-user endpoint. Working with the Pharmacology group at the University of Auckland, we have previously written an application using Globus Compute that can offload computationally expensive steps in the researcher's workflows, which they wish to manage from their familiar Windows environments, onto the NeSI (New Zealand eScience Infrastructure) cluster. Some of the challenges we have encountered were that each researcher had to set up and manage their own single-user globus compute endpoint and that the workloads had varying resource requirements (CPUs, memory and wall time) between different runs. We hope that the multi-user endpoint will help to address these challenges and share an update on our progress here.
Accelerate Enterprise Software Engineering with PlatformlessWSO2
Key takeaways:
Challenges of building platforms and the benefits of platformless.
Key principles of platformless, including API-first, cloud-native middleware, platform engineering, and developer experience.
How Choreo enables the platformless experience.
How key concepts like application architecture, domain-driven design, zero trust, and cell-based architecture are inherently a part of Choreo.
Demo of an end-to-end app built and deployed on Choreo.
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisGlobus
JASMIN is the UK’s high-performance data analysis platform for environmental science, operated by STFC on behalf of the UK Natural Environment Research Council (NERC). In addition to its role in hosting the CEDA Archive (NERC’s long-term repository for climate, atmospheric science & Earth observation data in the UK), JASMIN provides a collaborative platform to a community of around 2,000 scientists in the UK and beyond, providing nearly 400 environmental science projects with working space, compute resources and tools to facilitate their work. High-performance data transfer into and out of JASMIN has always been a key feature, with many scientists bringing model outputs from supercomputers elsewhere in the UK, to analyse against observational or other model data in the CEDA Archive. A growing number of JASMIN users are now realising the benefits of using the Globus service to provide reliable and efficient data movement and other tasks in this and other contexts. Further use cases involve long-distance (intercontinental) transfers to and from JASMIN, and collecting results from a mobile atmospheric radar system, pushing data to JASMIN via a lightweight Globus deployment. We provide details of how Globus fits into our current infrastructure, our experience of the recent migration to GCSv5.4, and of our interest in developing use of the wider ecosystem of Globus services for the benefit of our user community.
Your Digital Assistant.
Making complex approach simple. Straightforward process saves time. No more waiting to connect with people that matter to you. Safety first is not a cliché - Securely protect information in cloud storage to prevent any third party from accessing data.
Would you rather make your visitors feel burdened by making them wait? Or choose VizMan for a stress-free experience? VizMan is an automated visitor management system that works for any industries not limited to factories, societies, government institutes, and warehouses. A new age contactless way of logging information of visitors, employees, packages, and vehicles. VizMan is a digital logbook so it deters unnecessary use of paper or space since there is no requirement of bundles of registers that is left to collect dust in a corner of a room. Visitor’s essential details, helps in scheduling meetings for visitors and employees, and assists in supervising the attendance of the employees. With VizMan, visitors don’t need to wait for hours in long queues. VizMan handles visitors with the value they deserve because we know time is important to you.
Feasible Features
One Subscription, Four Modules – Admin, Employee, Receptionist, and Gatekeeper ensures confidentiality and prevents data from being manipulated
User Friendly – can be easily used on Android, iOS, and Web Interface
Multiple Accessibility – Log in through any device from any place at any time
One app for all industries – a Visitor Management System that works for any organisation.
Stress-free Sign-up
Visitor is registered and checked-in by the Receptionist
Host gets a notification, where they opt to Approve the meeting
Host notifies the Receptionist of the end of the meeting
Visitor is checked-out by the Receptionist
Host enters notes and remarks of the meeting
Customizable Components
Scheduling Meetings – Host can invite visitors for meetings and also approve, reject and reschedule meetings
Single/Bulk invites – Invitations can be sent individually to a visitor or collectively to many visitors
VIP Visitors – Additional security of data for VIP visitors to avoid misuse of information
Courier Management – Keeps a check on deliveries like commodities being delivered in and out of establishments
Alerts & Notifications – Get notified on SMS, email, and application
Parking Management – Manage availability of parking space
Individual log-in – Every user has their own log-in id
Visitor/Meeting Analytics – Evaluate notes and remarks of the meeting stored in the system
Visitor Management System is a secure and user friendly database manager that records, filters, tracks the visitors to your organization.
"Secure Your Premises with VizMan (VMS) – Get It Now"
A Comprehensive Look at Generative AI in Retail App Testing.pdfkalichargn70th171
Traditional software testing methods are being challenged in retail, where customer expectations and technological advancements continually shape the landscape. Enter generative AI—a transformative subset of artificial intelligence technologies poised to revolutionize software testing.
Why React Native as a Strategic Advantage for Startup Innovation.pdfayushiqss
Do you know that React Native is being increasingly adopted by startups as well as big companies in the mobile app development industry? Big names like Facebook, Instagram, and Pinterest have already integrated this robust open-source framework.
In fact, according to a report by Statista, the number of React Native developers has been steadily increasing over the years, reaching an estimated 1.9 million by the end of 2024. This means that the demand for this framework in the job market has been growing making it a valuable skill.
But what makes React Native so popular for mobile application development? It offers excellent cross-platform capabilities among other benefits. This way, with React Native, developers can write code once and run it on both iOS and Android devices thus saving time and resources leading to shorter development cycles hence faster time-to-market for your app.
Let’s take the example of a startup, which wanted to release their app on both iOS and Android at once. Through the use of React Native they managed to create an app and bring it into the market within a very short period. This helped them gain an advantage over their competitors because they had access to a large user base who were able to generate revenue quickly for them.
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...informapgpstrackings
Keep tabs on your field staff effortlessly with Informap Technology Centre LLC. Real-time tracking, task assignment, and smart features for efficient management. Request a live demo today!
For more details, visit us : https://informapuae.com/field-staff-tracking/
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Anthony Dahanne
Les Buildpacks existent depuis plus de 10 ans ! D’abord, ils étaient utilisés pour détecter et construire une application avant de la déployer sur certains PaaS. Ensuite, nous avons pu créer des images Docker (OCI) avec leur dernière génération, les Cloud Native Buildpacks (CNCF en incubation). Sont-ils une bonne alternative au Dockerfile ? Que sont les buildpacks Paketo ? Quelles communautés les soutiennent et comment ?
Venez le découvrir lors de cette session ignite
Modern design is crucial in today's digital environment, and this is especially true for SharePoint intranets. The design of these digital hubs is critical to user engagement and productivity enhancement. They are the cornerstone of internal collaboration and interaction within enterprises.
Experience our free, in-depth three-part Tendenci Platform Corporate Membership Management workshop series! In Session 1 on May 14th, 2024, we began with an Introduction and Setup, mastering the configuration of your Corporate Membership Module settings to establish membership types, applications, and more. Then, on May 16th, 2024, in Session 2, we focused on binding individual members to a Corporate Membership and Corporate Reps, teaching you how to add individual members and assign Corporate Representatives to manage dues, renewals, and associated members. Finally, on May 28th, 2024, in Session 3, we covered questions and concerns, addressing any queries or issues you may have.
For more Tendenci AMS events, check out www.tendenci.com/events
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus
As part of the DOE Integrated Research Infrastructure (IRI) program, NERSC at Lawrence Berkeley National Lab and ALCF at Argonne National Lab are working closely with General Atomics on accelerating the computing requirements of the DIII-D experiment. As part of the work the team is investigating ways to speedup the time to solution for many different parts of the DIII-D workflow including how they run jobs on HPC systems. One of these routes is looking at Globus Compute as a way to replace the current method for managing tasks and we describe a brief proof of concept showing how Globus Compute could help to schedule jobs and be a tool to connect compute at different facilities.
How to Position Your Globus Data Portal for Success Ten Good PracticesGlobus
Science gateways allow science and engineering communities to access shared data, software, computing services, and instruments. Science gateways have gained a lot of traction in the last twenty years, as evidenced by projects such as the Science Gateways Community Institute (SGCI) and the Center of Excellence on Science Gateways (SGX3) in the US, The Australian Research Data Commons (ARDC) and its platforms in Australia, and the projects around Virtual Research Environments in Europe. A few mature frameworks have evolved with their different strengths and foci and have been taken up by a larger community such as the Globus Data Portal, Hubzero, Tapis, and Galaxy. However, even when gateways are built on successful frameworks, they continue to face the challenges of ongoing maintenance costs and how to meet the ever-expanding needs of the community they serve with enhanced features. It is not uncommon that gateways with compelling use cases are nonetheless unable to get past the prototype phase and become a full production service, or if they do, they don't survive more than a couple of years. While there is no guaranteed pathway to success, it seems likely that for any gateway there is a need for a strong community and/or solid funding streams to create and sustain its success. With over twenty years of examples to draw from, this presentation goes into detail for ten factors common to successful and enduring gateways that effectively serve as best practices for any new or developing gateway.
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Globus
The U.S. Geological Survey (USGS) has made substantial investments in meeting evolving scientific, technical, and policy driven demands on storing, managing, and delivering data. As these demands continue to grow in complexity and scale, the USGS must continue to explore innovative solutions to improve its management, curation, sharing, delivering, and preservation approaches for large-scale research data. Supporting these needs, the USGS has partnered with the University of Chicago-Globus to research and develop advanced repository components and workflows leveraging its current investment in Globus. The primary outcome of this partnership includes the development of a prototype enterprise repository, driven by USGS Data Release requirements, through exploration and implementation of the entire suite of the Globus platform offerings, including Globus Flow, Globus Auth, Globus Transfer, and Globus Search. This presentation will provide insights into this research partnership, introduce the unique requirements and challenges being addressed and provide relevant project progress.
Code reviews are vital for ensuring good code quality. They serve as one of our last lines of defense against bugs and subpar code reaching production.
Yet, they often turn into annoying tasks riddled with frustration, hostility, unclear feedback and lack of standards. How can we improve this crucial process?
In this session we will cover:
- The Art of Effective Code Reviews
- Streamlining the Review Process
- Elevating Reviews with Automated Tools
By the end of this presentation, you'll have the knowledge on how to organize and improve your code review proces
How Recreation Management Software Can Streamline Your Operations.pptxwottaspaceseo
Recreation management software streamlines operations by automating key tasks such as scheduling, registration, and payment processing, reducing manual workload and errors. It provides centralized management of facilities, classes, and events, ensuring efficient resource allocation and facility usage. The software offers user-friendly online portals for easy access to bookings and program information, enhancing customer experience. Real-time reporting and data analytics deliver insights into attendance and preferences, aiding in strategic decision-making. Additionally, effective communication tools keep participants and staff informed with timely updates. Overall, recreation management software enhances efficiency, improves service delivery, and boosts customer satisfaction.
How Recreation Management Software Can Streamline Your Operations.pptx
Doubly & Circular Linked Lists
1. Double & Circular Linked Lists
Prepared by: Afaq Mansoor Khan
BSSE III- Group A
Session 2017-21
IMSciences, Peshawar.
2. Last Lecture Summary
• Insertion in Linked List with following criteria
▫ Start of the list
▫ End of the list
▫ Middle of the list
▫ Anywhere in the list
• Deletion of a node from
▫ The Tail of the List
▫ The Head of the List
▫ A desired location in the list
▫ Delete node with a particular value
3. Objectives Overview
• Introduction to Double Linked List
• Insertions and Deletions in Doubly Linked List
• Introduction to Circular Linked List
• Insertion and Deletion in Circular Linked List
4. Doubly Linked List
• In a doubly linked list, each node contains a data part
and two addresses, one for the previous node and
one for the next node.
7. Inserting into a Doubly Linked List
A Node can be added in four ways:
1) At the front of the DLL
2) After a given node.
3) At the end of the DLL
4) Before a given node.
8. Insertion at the Front - Algorithm
Steps:
1. Allocate node
2. Put in the data
3. Make next of new node as head and
previous as NULL
4. Change previous of head node to new
node
5. Move the head to point to the new
node
10. Insertion at the Front - Implementation
• void push(struct Node** head_ref, int new_data) {
• struct Node* new_node = (struct Node*)malloc(sizeof(struct Node));
• new_node->data = new_data;
• new_node->next = (*head_ref);
• new_node->prev = NULL;
• if ((*head_ref) != NULL)
▫ (*head_ref)->prev = new_node;
• (*head_ref) = new_node;
• }
11. Insertion after a given Node - Algorithm
Steps:
1. Check if the given previous node is NULL
2. Allocate new node
3. Put in the data
4. Make next of new node as next of previous
node
5. Make the next of previous node as new
node
6. Make previous node as previous of new
node
7. Change previous of new node's next node
13. Insertion after a given Node - Implementation
• void insertAfter(struct Node* prev_node, int new_data)
• {
• if (prev_node == NULL) {
• printf("the given previous node cannot be NULL");
• return;
• }
• struct Node* new_node = (struct Node*)malloc(sizeof(struct Node));
• new_node->data = new_data;
• new_node->next = prev_node->next;
• prev_node->next = new_node;
• new_node->prev = prev_node;
• if (new_node->next != NULL)
• new_node->next->prev = new_node;
• }
14. Insertion at the End - Algorithm
Steps:
1. Allocate node
2. Put in the data
3. This new node is going to be the last node, so
make next of it as NULL
4. If the Linked List is empty, then make the new
node as head
5. Else traverse till the last node
6. Change the next of last node
7. Make last node as previous of new node
16. Insertion at the End - Implementation
• void append(struct Node** head_ref, int new_data)
• {
• struct Node* new_node = (struct Node*)malloc(sizeof(struct Node));
•
• struct Node* last = *head_ref; /* used in step 5*/
• new_node->data = new_data;
• new_node->next = NULL;
•
• if (*head_ref == NULL) {
• new_node->prev = NULL;
• *head_ref = new_node;
• return;
• }
• while (last->next != NULL)
• last = last->next;
• last->next = new_node;
• new_node->prev = last;
•
• return;
• }
17. Insertion before a given Node - Algorithm
Steps:
1. Check if the given next node is NULL
2. Allocate new node
3. Put in the data
4. Make previous of new node as previous of next node
5. Make the previous of next node as new node
6. Make next node as next of new node
7. Change next of new node's previous node
21. Algorithm
Let the node to be deleted is del.
1) If node to be deleted is head node, then change the
head pointer to next current head.
2) Set next of previous to del, if previous to del exists.
3) Set prev of next to del, if next to del exists.
26. Advantages over Singly Linked List
• 1) A DLL can be traversed in both forward and backward
direction.
2) The delete operation in DLL is more efficient if pointer to
the node to be deleted is given.
3) We can quickly insert a new node before a given node.
In singly linked list, to delete a node, pointer to the previous
node is needed. To get this previous node, sometimes the list
is traversed. In DLL, we can get the previous node using
previous pointer.
27. Disadvantages over Singly Linked List
• 1) Every node of DLL Require extra space for an previous
pointer. It is possible to implement DLL with single pointer
though.
2) All operations require an extra pointer previous to be
maintained. For example, in insertion, we need to modify
previous pointers together with next pointers. For example in
following functions for insertions at different positions, we
need 1 or 2 extra steps to set previous pointer.
32. Insertion
A Node can be inserted in four ways:
1. Insertion in an empty list
2. Insertion at the beginning of the
list
3. Insertion at the end of the list
4. Insertion in between the nodes
33. Insertion in an Empty List - Algorithm
• Initially when the list is empty, last pointer will be
NULL.
• Insert a node T,
• After insertion, T is the last node so pointer last
points to node T.
• Node T is first and last node, so T is pointing to itself.
35. Implementation
struct Node *addToEmpty(struct Node *last, int data)
{
// This function is only for empty list
if (last != NULL)
return last;
// Creating a node dynamically.
struct Node *last =
(struct Node*)malloc(sizeof(struct Node));
// Assigning the data.
last -> data = data;
// Note : list was empty. We link single node
// to itself.
last -> next = last;
return last;
}
36. Insertion at the Beginning - Algorithm
To Insert a node at the beginning of the list, follow
these steps:
1. Create a node, say T.
2. Make T -> next = last -> next.
3. last -> next = T.
39. Implementation
struct Node *addBegin(struct Node *last, int data)
{
if (last == NULL)
return addToEmpty(last, data);
struct Node *temp = (struct Node *)malloc(sizeof(struct Node));
temp -> data = data;
// Adjusting the links.
temp -> next = last -> next;
last -> next = temp;
return last;
}
40. Insertion at the End - Algorithm
To Insert a node at the end of the list, follow these
steps:
1. Create a node, say T.
2. Make T -> next = last -> next;
3. last -> next = T.
4. last = T.
43. Implementation
struct Node *addEnd(struct Node *last, int data)
{
if (last == NULL)
return addToEmpty(last, data);
struct Node *temp =
(struct Node *)malloc(sizeof(struct Node));
temp -> data = data;
temp -> next = last -> next;
last -> next = temp;
last = temp;
return last;
}
44. Insertion in between the Nodes - Algorithm
To Insert a node in between the Nodes, follow these
steps:
1. Create a node, say T.
2. Search the node after which T need to be insert,
say that node be P.
3. Make T -> next = P -> next;
4. P -> next = T.
47. Implementation
struct Node *addAfter(struct Node *last, int data, int item)
{
if (last == NULL)
return NULL;
struct Node *temp, *p;
p = last -> next;
do
{
if (p ->data == item)
{
temp = (struct Node *)malloc(sizeof(struct Node));
temp -> data = data;
temp -> next = p -> next;
p -> next = temp;
if (p == last)
last = temp;
return last;
}
p = p -> next;
} while (p != last -> next);
cout << item << " not present in the list." << endl;
return last;
}
49. Deletion in Circular Linked List
There are three situation for Deleting element in list.
1. Deletion at beginning.
2. Deletion at the middle.
3. Deletion at the end.
50. Deletion - Algorithm
Steps:
• Create a circular linked list and assign reference of first node to head.
• Input key to delete from user. Store it in some variable say key. Say key to
delete is 20.
• To keep track of previous node and node to delete, declare two variables
of node type. Say cur = head and prev. Make sure previous points to last
node.
• If current node contains key, Then you got node to delete.
• Before deleting a node, you must first adjust previous node link.
• Adjust head node if needed.
• Delete the node.
• Update current node, i.e. assign cur = previous->next if previous != NULL.
Otherwise assign NULL.
• If current node does not contain key to delete, then simply update
previous and current node.
• Repeat step 3-4 till last node.
58. Summary
• Introduction to Double Linked List
• Insertions and Deletions in Doubly Linked List
• Introduction to Circular Linked List
• Insertion and Deletion in Circular Linked List