Data Structure
  • টাইম এন্ড স্পেস কমপ্লেক্সিটি
    • সূচনা
    • টাইম কমপ্লেক্সিটি
    • O(N) টাইম কমপ্লেক্সিটি
    • O(logN) টাইম কমপ্লেক্সিটি
    • O(sqrt(N)) টাইম কমপ্লেক্সিটি
    • টাইম কমপ্লেক্সিটির কিছু উদাহরন
    • টাইম কমপ্লেক্সিটি থেকে টাইম ক্যালকুলেট করা
    • স্পেস কমপ্লেক্সিটি
  • মডিউল ২ঃ STL Vector
    • ২-০ঃ সূচনা
    • ২-১ঃ ভেক্টর ইনিশিয়ালাইজেশন এবং কন্সট্রাক্টর
    • ২-২ঃ ভেক্টর ক্যাপাসিটি ফাংশন
    • ২-৩ঃ ভেক্টর মডিফাইয়ার ফাংশন -১
    • ২-৪ঃ ভেক্টর মডিফাইয়ার ফাংশন -২
    • ২-৫ঃ ভেক্টর এক্সেস এবং ইটারেটর
    • ২-৬ঃ ভেক্টরে ইনপুট নেয়া
    • ২-৭ঃ স্ট্রিং এর ভেক্টর
  • Prefix Sum and Binary Search
    • সূচনা
    • Range Sum Query (Codeforces)
    • Prefix Sum পরিচিতি
    • Prefix sum ইমপ্লিমেন্টেশন
    • Binary Search (Codeforces)
    • বাইনারি সার্চ পরিচিতি
    • বাইনারি সার্চ ইমপ্লিমেন্টেশন
  • মডিউল ৫ঃ Singly Linked List
    • ৫-০ঃ সূচনা
    • ৫-১ঃ Linked List কেন?
    • ৫-২ঃ Linked List কেন? (পার্ট ২)
    • ৫-৩ঃ Create a Node
    • ৫-৪ঃ Constructor of Node
    • ৫-৫ঃ Dynamic Node
    • ৫-৬ঃ Singly Linked List কিভাবে তৈরি হয়
    • ৫-৭ঃ Printing Singly Linked List
    • ৫-৮ঃ Printing Singly Linked List (Animated)
  • মডিউল ৬ঃ Singly Linked List Operation
    • ৬-০ঃ সূচনা
    • ৬-১ঃ পয়েন্টারের রেফারেন্স
    • ৬-২ঃ Tail এ ভ্যালু Insertion
    • ৬-৩ঃ যেকোন পজিশনে ভ্যালু Insertion
    • ৬-৪ঃ Head এ ভ্যালু Insertion
    • ৬-৫ঃ যেকোন পজিশনের ভ্যালু Deletion
    • ৬-৬ঃ Head ডিলিট
    • ৬-৭ঃ Error Handling
    • ৬-৮ঃ Singly Linked List এ ইনপুট
  • মডিউল ৭ঃ Singly Linked List recap
    • ৭-০ঃ সূচনা
    • ৭-১ঃ Singly Linked List recap
    • ৭-২ঃ Insert at Singly Linked List Recap
    • ৭-৩ঃ Insert at Head and Tail at Singly Linked List Recap
    • ৭-৪ঃ Delete from Singly Linked List Recap
    • ৭-৫ঃ Delete Head from Singly Linked List Recap
    • ৭-৬ঃ Take Singly Linked List Input Recap
    • ৭-৭ঃ Printing Singly Linked List in Reverse
    • ৭-৮ঃ Sort Singly Linked List
    • ৭-বোনাসঃ Singly Linked list all operations complexity analysis
  • মডিউল ৯: Doubly Linked List
    • ৯-০ঃ সূচনা
    • ৯ -১ঃ Doubly Linked List
    • ৯-২ঃ Doubly Linked List দেখতে কেমন?
    • ৯-৩ঃ Doubly Linked List এর যেকোনো position এ value insert
    • ৯-৪ঃ Insert at Head and Tail in Doubly Linked List
    • ৯-৫ঃ Insert Operation on Doubly Linked List Animated
    • ৯-৬ঃ Delete Operations on Doubly Linked List
    • ৯-৭ঃ Complexity Analysis
    • মডিউল ৯-৮ঃ Doubly Linked List এ input নেয়া
  • মডিউল ১০: STL List and Cycle Detection
    • ১০-০ঃ সূচনা
    • ১০-১ঃ List Constructors
    • ১০-২ঃ List Capacity Functions
    • ১০-৩ঃ List Modifiers Functions
    • ১০-৪ঃ List Operations and Access Related Function
    • ১০-৫ , ১০-৬ঃ Reverse a Singly Linked List
    • ১০-৭ঃ Reverse a Doubly Linked List
    • ১০-৮ঃ Detect Cycle in Singly Linked List
  • মডিউল ১১ঃ Problem Solving using Linked list
    • মডিউল ১১-০ঃ সূচনা
    • মডিউল ১১-১ঃ Middle of the Linked List
    • মডিউল ১১-২ঃ Linked List Cycle
    • মডিউল ১১-৩ঃ Remove Duplicate from Sorted List
    • মডিউল ১১-৪ঃ Reverse Linked List
    • মডিউল ১১-৫ঃ Palindrome Linked List
    • মডিউল ১১-৬ঃ Delete Node in a Linked List
  • Module 13: Stack Implementation and STL
    • মডিউল ১৩-০ঃ সূচনা
    • মডিউল ১৩-১ঃ What is stack (animation)
    • মডিউল ১৩-২,৩ঃ What is stack
    • মডিউল ১৩- ৪,৫ঃ Stack Implement using Array
    • মডিউল ১৩-৬ঃ Stack Implement using List
    • মডিউল ১৩-৭ঃ Stack Implement using Doubly Linked List
    • মডিউল ১৩-৮ঃ STL Stack
  • মডিউল ১৪ঃ Queue Implmentation and STL
    • ১৪-০ঃ সূচনা
    • ১৪-১,১৪-২ঃ Queue কী এবং Queue এর কিছু বাস্তব উদাহরণ
    • ১৪-৩ঃ Singly Linked List এর সাহায্যে Queue তৈরি করা
    • ১৪-৪ঃ Doubly Linked List এর সাহায্যে Queue তৈরি করা
    • ১৪-৫ঃ STL List এর সাহায্যে Queue তৈরি করা
    • ১৪-৬ঃ Queue এর STL লাইব্রেরি
    • ১৪-৭ঃImplement Stack using Queue (Leetcode)
    • ১৪-৮ঃ Implement Queue using Stacks (Leetcode)
  • মডিউল ১৫ঃ Problem Solving using Stack & Queue
    • মডিউল ১৫-০ঃ সূচনা
    • মডিউল ১৫-১ঃ Valid Parentheses (Leetcode)
    • মডিউল ১৫-২ঃ Backspace String Compare (Leetcode)
    • মডিউল ১৫-৩ঃ Insert Element At Bottom of Stack (CodingNinjas)
    • মডিউল ১৫-৪ঃ Maximum Equal Stack Sum (CodingNinjas)
    • মডিউল ১৫-৫ঃ Reversing a Queue (CodingNinjas)
    • মডিউল ১৫-৬ঃ Reverse Stack Using Recursion (CodingNinjas)
  • মডিউল ১৭: Binary Tree Implementation
    • মডিউল ১৭-০ঃ সূচনা
    • মডিউল ১৭-১ঃ Discussion about Tree Data Structure
    • মডিউল ১৭-৩ঃ Discussion about Binary Tree
    • মডিউল ১৭- ৪ঃ Create a Binary Tree
    • মডিউল ১৭-৫ঃ Pre Order Traversal of Binary Tree
    • মডিউল ১৭-৭ঃ Post Order Traversal of Binary Tree
    • মডিউল ১৭-৮ঃ In Order Traversal of Binary Tree
  • মডিউল ১৮ঃ Operations On Binary Tree
    • ১৮-০ঃ সূচনা
    • ১৮-১ঃ Level Order Traversal of Binary Tree থিওরি
    • ১৮-২ঃ Level Order Traversal of Binary Tree ইমপ্লিমেন্টেশন
    • ১৮-৩ঃ Binary Tree Input থিওরি
    • ১৮-৪ঃ Binary Tree Input ইমপ্লিমেন্টেশন
    • ১৮-৫ঃ Count Number of Nodes of a Binary Tree
    • ১৮-৬ঃ Count Number of Leaf Nodes of a Binary Tree
    • মডিউল ১৮-৭ঃGet the Maximum Height of a Binary Tree
  • মডিউল ১৯ঃ Problem Solving using Binary Tree
    • মডিউল ১৯-০ঃ সূচনা
    • মডিউল ১৯-১ঃ Is Node Present (Coding Ninjas)
    • মডিউল ১৯-২ঃ STL Pair, Node Level (Coding Ninjas)
    • মডিউল ১৯-৩ঃ Left View Of a Binary Tree (Coding Ninjas)
    • মডিউল ১৯-৪ঃ Diameter Of Binary Tree (Coding Ninjas)
    • মডিউল ১৯-৫ঃ Special Binary Tree (Coding Ninjas)
    • মডিউল ১৯-৬ঃ Reverse Level Order Traversal (Coding Ninjas)
  • মডিউল ২১ঃ Binary Search Tree Implementation
    • মডিউল ২১-০ঃ সূচনা
    • মডিউল ১৭-১ঃ What is BST
    • মডিউল ২১-২ঃ How to Handle Duplicate in BST
    • মডিউল ২১-৩ঃ Search in BST
    • মডিউল ২১-৫ঃ Insert in BST
    • মডিউল ২১-৭ঃ Convert Array to BST
  • মডিউল ২২ঃ Heap Implmentation
    • ২২-০ঃ সূচনা
    • ২২-১ঃ Complete Binary Tree কী
    • ২২-২ঃ Complete Binary Tree এর Array Representation
    • ২২-৩ঃ Heap কী
    • ২২-৪ঃ Heap এ Insertion এর থিওরি
    • ২২-৫ঃ Heap এ Insertion ইমপ্লিমেন্টেশন
    • ২২-৬ঃ Heap এ Deletion থিওরি
    • ২২-৭ঃ Heap এ Deletion ইমপ্লিমেন্টেশন
  • মডিউল ২৩ঃ STL Priority Queue, Map and Set
    • মডিউল ২৩-০ঃ সূচনা
    • মডিউল ২৩-১ঃ Priority Queue কি?
    • মডিউল ২৩-২ঃ কিভাবে STL Priority Queue কাজ করে
    • মডিউল ২৩-৩ঃ Custom Compare Class for Priority Queue
    • মডিউল ২৩-৪ঃ map কি?
    • মডিউল ২৩-৫ঃ কিভাবে STL map কাজ করে
    • মডিউল ২৩-৬ঃ Count Words in a String using Map
    • মডিউল ২৩-৭ঃ কিভাবে STL set কাজ করে
Powered by GitBook
On this page
  1. মডিউল ৯: Doubly Linked List

৯-৭ঃ Complexity Analysis

Previous৯-৬ঃ Delete Operations on Doubly Linked ListNextমডিউল ৯-৮ঃ Doubly Linked List এ input নেয়া

Last updated 10 months ago

এখন আমরা array, singly linked list, doubly linked list এর বিভিন্ন method/task এর time complexity দেখে নেই। এতে করে আমরা এই 3 ধরনের data structure এর মধ্যে কোনটা বেশি efficient তা বের করা চেষ্টা করবো।

Insert at head: এই Task এ array তে সবচেয়ে বেশি complexity লাগছে, কারণ array এর ক্ষেত্রে আমাদের বাকি সব valueকে অন্য position এ নিয়ে তারপর head এ value insert করতে হয়। অন্যদিকে singly and doubly linked list এ head node এর সাথে new node এর connection create করলেই হয়ে যায়।

Insert at tail: এইক্ষেত্রে কোনো value shift করতে হচ্ছে না just last এ add করতে হচ্ছে তাই সবক্ষেত্রে same complexity কাজ করছে।

Insert at position: এখানে 3 টা data structure এই same O(n) আসে। কারণ প্রতিবার আমাদের একটা নির্দিষ্ট position এ অব্দি loop চালাতে হচ্ছে।

Delete head: singly ও doubly linked list এ head track রাখা যায় আর delete করা মানে head এ যে node আছে সেটা disconnect করে দেয়া মূলত, তাই এদের বেলায় O(1) complexity. আর array এর বেলায় delete head এ কোনো value delete করতে হলে পরের value গুলোর position shift করতে হবে, তাই array এর জন্য O(n) complexity আসে।

Delete tail: এখানে array এবং doubly linked list এ শেষ position টা আমরা track রাখতে পারি বা সহজে access করতে পারি, তাই শেষ বা tail value delete করতে আমাদের O(1) complexity হয়। কিন্তু singly linked list এর বেলায় tail track রাখা হয় না , তাই tail অব্দি যেতে আমাদের পুরো list ঘুরে যেতে হয়। তাই এর tail delete করার জন্য আমাদের singly list এর জন্য O(n) complexity আসে।

Delete at position: insert এর মতো delete এর বেলায় ও ঠিক একই logic এর জন্য এই 3 data structure (array, signly linked list and doubly linked list) এর জন্য O(n) complexity পাওয়া যাচ্ছে।

Time Complexity Comparison of Array vs Linked Lists