@@ -17,7 +17,7 @@ struct Deque *createDeque(struct Deque *root, int key) //Function to create dequ
17
17
head = root ;
18
18
last = root ;
19
19
return head ;
20
- }
20
+ } //O(1) time complexity
21
21
22
22
struct Deque * push_front (struct Deque * root , int key ) //Function to push element on the front of deque
23
23
{
@@ -31,7 +31,7 @@ struct Deque *push_front(struct Deque *root, int key) //Function to push element
31
31
temp -> next = head ;
32
32
head = temp ;
33
33
return head ;
34
- }
34
+ } //O(1) time complexity
35
35
36
36
struct Deque * push_back (struct Deque * root , int key ) //Function to push element to the back of deque
37
37
{
@@ -46,7 +46,7 @@ struct Deque *push_back(struct Deque *root, int key) //Function to push element
46
46
last -> next = temp ;
47
47
last = temp ;
48
48
return last ;
49
- }
49
+ } //O(1) time complexity
50
50
51
51
struct Deque * pop_front () //Function to remove or pop the front element
52
52
{
@@ -60,7 +60,7 @@ struct Deque *pop_front() //Function to remove or pop the front element
60
60
head = head -> next ;
61
61
free (temp ); //free the unwanted space
62
62
return head ;
63
- }
63
+ } //O(1) time complexity
64
64
65
65
struct Deque * pop_back () //Function to remove element from back of deque
66
66
{
@@ -80,7 +80,7 @@ struct Deque *pop_back() //Function to remove element from back of deque
80
80
last = temp ;
81
81
free (temp2 );//free the unwanted space
82
82
return head ;
83
- }
83
+ } //O(n) time complexity
84
84
85
85
void front () //Function to give the front element of deque
86
86
{
@@ -89,7 +89,7 @@ void front() //Function to give the front element of deque
89
89
printf ("Deque is empty.\n\n" );
90
90
}
91
91
printf ("The element at the front of deque is %d.\n\n" , head -> data );
92
- }
92
+ } //O(1) time complexity
93
93
94
94
void back () //Function to give the back of deque
95
95
{
@@ -98,7 +98,7 @@ void back() //Function to give the back of deque
98
98
printf ("Deque is empty\n" );
99
99
}
100
100
printf ("The element at the last of deque is %d.\n\n" , last -> data );
101
- }
101
+ } //O(1) time complexity
102
102
103
103
void isEmpty () //Function to know whether deque is empty or not
104
104
{
@@ -110,7 +110,7 @@ void isEmpty() //Function to know whether deque is empty or not
110
110
{
111
111
printf ("No, list is not empty.\n\n" );
112
112
}
113
- }
113
+ } //O(1) time complexity
114
114
115
115
void displayTheDeque () //Function to print the whole deque
116
116
{
@@ -130,7 +130,8 @@ void displayTheDeque() //Function to print the whole deque
130
130
}
131
131
printf (" <-----End\n\n" );
132
132
}
133
- }
133
+ } //O(n) time complexity
134
+
134
135
int main ()
135
136
{
136
137
struct Deque * root = NULL ;
0 commit comments