kruti-working-branch #14

Closed
kruti wants to merge 15 commits from kruti/Princeton1:kruti-working-branch into main
Owner

Description

  • Stack, Queue and Sort implementation
## Description - Stack, Queue and Sort implementation
kruti self-assigned this 2025-02-09 15:48:24 +00:00
kruti added 12 commits 2025-02-09 15:48:24 +00:00
kruti requested review from hitanshu 2025-02-09 15:50:08 +00:00
hitanshu requested changes 2025-02-09 19:24:45 +00:00
Dismissed
hitanshu left a comment
Owner

Good job <3 !!

Good job <3 !!
@ -37,1 +31,3 @@
return element;
E currentValue = start.data;
start = start.next;
return currentValue;
Owner

Case where only 1 element in queue, end pointer is dangling.

Case where only 1 element in queue, end pointer is dangling.
hitanshu marked this conversation as resolved
@ -15,3 +17,3 @@
}
// Will return true if size is 0
Node<E> head = null;
Owner

Why do you need two pointers, both insertion and deletion happen at head

Why do you need two pointers, both insertion and deletion happen at head
hitanshu marked this conversation as resolved
@ -23,2 +19,2 @@
mergesort(arr, aux, mid+1, hi);
merge(arr, aux, lo, mid, hi);
// Copy array
E[] auxArr = (E[]) new Object[high_index - low_index + 1];
Owner

Making a new aux arry with each recursive call is expensive

Making a new aux arry with each recursive call is expensive
hitanshu marked this conversation as resolved
kruti added 1 commit 2025-02-12 18:28:38 +00:00
Code improvements
All checks were successful
sample gradle build and test / build (pull_request) Successful in 1m4s
ca1391130d
kruti requested review from hitanshu 2025-02-12 18:29:55 +00:00
kruti added 1 commit 2025-02-12 19:14:12 +00:00
Array queue wraping
All checks were successful
sample gradle build and test / build (pull_request) Successful in 1m25s
026b6c1d09
hitanshu requested changes 2025-02-12 21:58:12 +00:00
Dismissed
@ -94,0 +51,4 @@
queueArray = (E[]) new Object[targetSize];
int j = 0;
for(int i=startPtr; i<endPtr; i++)
queueArray[j++]=tempArray[i];
Owner

If the old queue is wrapped, then endPtr will be less than startPtr

If the old queue is wrapped, then endPtr will be less than startPtr
hitanshu marked this conversation as resolved
@ -103,0 +74,4 @@
@Override
public E next() {
return queueArray[iteratorIndex++];
Owner

Iterator does not account for wrapping

Iterator does not account for wrapping
hitanshu marked this conversation as resolved
kruti added 1 commit 2025-02-13 17:19:03 +00:00
queue wrapping bug fixes
All checks were successful
sample gradle build and test / build (pull_request) Successful in 1m3s
e24ed7cf50
kruti requested review from hitanshu 2025-02-13 17:21:17 +00:00
hitanshu approved these changes 2025-02-13 17:33:45 +00:00
hitanshu closed this pull request 2025-02-13 17:34:03 +00:00
All checks were successful
sample gradle build and test / build (pull_request) Successful in 1m3s

Pull request closed

Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Hithomelabs/Princeton1#14
No description provided.