From c94373473c03166c3d4f6641b561b244e954accd Mon Sep 17 00:00:00 2001 From: GauravWalia19 Date: Mon, 17 Dec 2018 20:04:17 +0530 Subject: [PATCH] added complexity for queues --- C/README.md | 14 +++++++++ docs/complexity.md | 73 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) diff --git a/C/README.md b/C/README.md index d1da692..75d2657 100644 --- a/C/README.md +++ b/C/README.md @@ -38,6 +38,20 @@ * [Minimum bracket reversal for balanced expression](Data-Structures/STACKS/MISC-STACKS/minimum_bracket_reversal_for_balanced_expression.c) * [Postfix Evaluation](Data-Structures/STACKS/MISC-STACKS/postfix_evaluation.c) +#### QUEUES + +* SIMPLE QUEUE + * FIXED ARRAY + * DYNAMIC ARRAY + * LINKED +* CIRCULAR QUEUE + * FIXED ARRAY + * LINKED +* PRIORITY QUEUE + * FIXED ARRAY + * DYNAMIC ARRAY + * LINKED + #### HEAPS * [1D ARRAYS USING HEAPS](Data-Structures/HEAPS/dynamicarray.c) diff --git a/docs/complexity.md b/docs/complexity.md index c616b28..887ace7 100644 --- a/docs/complexity.md +++ b/docs/complexity.md @@ -86,6 +86,17 @@ This page contains the complexities of different algorithms in this repository. * C++ * [MISC STACKS](#misc-stacks) * QUEUES + * SIMPLE QUEUE + * FIXED ARRAY SIMPLE QUEUE + * DYNAMIC ARRAY SIMPLE QUEUE + * LINKED SIMPLE QUEUE + * CIRCULAR QUEUE + * FIXED ARRAY CIRCULAR QUEUE + * LINKED CIRCULAR QUEUE + * PRIORITY QUEUE + * FIXED ARRAY PRIORITY QUEUE + * LINKED PRIORITY QUEUE + * HEAPED PRIORITY QUEUE * HASHTABLE * TREES * HEAPS @@ -386,6 +397,68 @@ SNo. | Operations | Order and Type of Time Complexity O(n) | Order and Type of S ### QUEUES +#### SIMPLE QUEUE + +##### FIXED ARRAY SIMPLE QUEUE + + SNo. | Operations | Order and Type of Time Complexity O(n) | Order and Type of Space Complexity + ---- | ---------- | -------------------------------------- | ---------------------------------- + 1 | Enqueue an element or Insert element | O(1) -- Constant | O(1) -- Constant + 2 | Dequeue an element or Delete element | O(1) -- Constant | O(1) -- Constant + 3 | Print the queue | O(n) -- Linear | O(1) -- Constant + 4 | Size of the queue | O(1) -- Constant | O(1) -- Constant + 5 | Queue is Empty or not | O(1) -- Constant | O(1) -- Constant + +##### DYNAMIC ARRAY SIMPLE QUEUE + + SNo. | Operations | Order and Type of Time Complexity O(n) | Order and Type of Space Complexity + ---- | ---------- | -------------------------------------- | ---------------------------------- + 1 | Enqueue an element or Insert element | O(1) -- Constant | O(log n) -- Logarthmic + 2 | Dequeue an element or Delete element | O(1) -- Constant | O(1) -- Constant + 3 | Print the queue | O(n) -- Linear | O(1) -- Constant + 4 | Size of the queue | O(1) -- Constant | O(1) -- Constant + 5 | Queue is Empty or not | O(1) -- Constant | O(1) -- Constant + +##### LINKED SIMPLE QUEUE + + SNo. | Operations | Order and Type of Time Complexity O(n) | Order and Type of Space Complexity + ---- | ---------- | -------------------------------------- | ---------------------------------- + 1 | Enqueue an element or Insert element | O(n) -- Linear | O(1) -- Constant + 2 | Dequeue an element or Delete element | O(1) -- Constant | O(1) -- Constant + 3 | Print the queue | O(n) -- Linear | O(1) -- Constant + 4 | Size of the queue | O(1) -- Constant | O(1) -- Constant + 5 | Queue is Empty or not | O(1) -- Constant | O(1) -- Constant + +#### CIRCULAR QUEUE + +##### FIXED ARRAY CIRCULAR QUEUE + + SNo. | Operations | Order and Type of Time Complexity O(n) | Order and Type of Space Complexity + ---- | ---------- | -------------------------------------- | ---------------------------------- + 1 | Enqueue an element or Insert element | O(1) -- Constant | O(1) -- Constant + 2 | Dequeue an element or Delete element | O(1) -- Constant | O(1) -- Constant + 3 | Print the queue | O(n) -- Linear | O(1) -- Constant + 4 | Size of the queue | O(1) -- Constant | O(1) -- Constant + 5 | Queue is Empty or not | O(1) -- Constant | O(1) -- Constant + +##### LINKED CIRCULAR QUEUE + +#### PRIORITY QUEUE + +##### FIXED ARRAY PRIORITY QUEUE + +##### LINKED PRIORITY QUEUE + + SNo. | Operations | Order and Type of Time Complexity O(n) | Order and Type of Space Complexity + ---- | ---------- | -------------------------------------- | ---------------------------------- + 1 | Insert element with priority | O(n) -- Linear | O(1) -- Constant + 2 | Delete element with highest priority | O(1) -- Constant | O(1) -- Constant + 3 | Print the queue | O(n) -- Linear | O(1) -- Constant + 4 | Size of the queue | O(1) -- Constant | O(1) -- Constant + 5 | Queue is Empty or not | O(1) -- Constant | O(1) -- Constant + +##### HEAPED PRIORITY QUEUE + ### HASHTABLE ### TREES