



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An explanation of worst-case complexity in computer science and how to analyze it in the context of two loops and a nested loop. Additionally, it introduces a circular linked list and provides C++ code for implementing a circular linked list, including functions for pushing, inserting after, appending, and printing the list.
Typology: Quizzes
1 / 5
This page cannot be seen from the preview
Don't miss anything!




In computer science, the complexity of the worst case scenario (usually the asymptomatic symbol) measures the resources (such as running time, memory) that are given input at an arbitrary size by the algorithm (usually N or NK). Also known as). It sets a limit on the resources required by the algorithm.
Circular LinkedIn List is a variant of a linked list in which the first element refers to the last element and the last element refers to the first element. Both single linked list and double linked list can be made circular linked list.
#include <bits/stdc++.h> using namespace std; class Node
public: int data; Node* next; Node* prev; }; void push(Node** head_ref, int new_data) { Node* new_node = new Node(); new_node->next = (head_ref); new_node->data = new_data; new_node->prev = NULL; if ((head_ref) != NULL) (head_ref)->prev = new_node; (head_ref) = new_node; } void insertAfter(Node* prev_node, int new_data) { if (prev_node == NULL) { cout<<"the given previous node cannot be NULL"; return; } Node* new_node = new Node(); new_node->data = new_data;
Node* last; cout<<"\nTraversal in forward direction \n"; while (node != NULL) { cout<<" "<<node->data<<" "; last = node; node = node->next; } cout<<"\nTraversal in reverse direction \n"; while (last != NULL) { cout<<" "<<last->data<<" "; last = last->prev; } } int main() { Node* head = NULL; push(&head, 8); push(&head, 4); append(&head,7); insertAfter(head->next, 1);
cout << "\nCreated DLL is:"; printList(head); return 0; }