Skip to content

Fire - Noor#23

Open
hn4ever wants to merge 8 commits into
Ada-C14:masterfrom
hn4ever:master
Open

Fire - Noor#23
hn4ever wants to merge 8 commits into
Ada-C14:masterfrom
hn4ever:master

Conversation

@hn4ever
Copy link
Copy Markdown

@hn4ever hn4ever commented Apr 22, 2021

Stacks and Queues

Thanks for doing some brain yoga. You are now submitting this assignment!

Comprehension Questions

Question Answer
What is an ADT? A type of object where it's described by its methods.
Describe a Stack A data structure in which stores a list of data that can only be accessed in 'Last In First Out' order.
What are the 5 methods in Stack and what does each do? They are: push (to add an item at the top), pop (to remove an item from the top), is_empty(to check if the stack is empty), peek (return the value of the top item without removing it), size (return the number of items in the stack)
Describe a Queue A type of data structure in which stores a list of data that are only accessible in a 'First In First Out' Order.
What are the 5 methods in Queue and what does each do? They are: enqueue (to add an item at the back of the queue, dequeue (to remove an item from the front of the queue), is_empty (checks if a queue is empty or not), front (return the value of the front item without removing it), and size (return number of items in a queue
What is the difference between implementing something and using something? If we use something, we will not need to know how it was implemented, while if we implement something we need to know most of its use cases.

OPTIONAL JobSimulation

Question Answer
Did you include a sample run of your code as a comment?

Copy link
Copy Markdown

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done Noor, you hit the learning goals here. Well done.

Comment thread lib/queue.rb
@front = @back = 0
end

def enqueue(element)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread lib/queue.rb
@back = (@back + 1) % Array_Length
end

def dequeue
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 , very compact, nicely done!

Comment thread lib/queue.rb
return @store[@front]
end

def size
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread lib/queue.rb
end
end

def empty?
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread lib/stack.rb
@@ -1,19 +1,20 @@
class Stack
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@hn4ever
Copy link
Copy Markdown
Author

hn4ever commented May 11, 2021

Thank you Chris :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants