Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Challenge Q1 (not graded, but fun to try!) You know how to write a stack now. Could you implement a Queue using F# stack? The

Challenge Q1 (not graded, but fun to try!)

You know how to write a stack now. Could you implement a Queue using F# stack? The goal of this question is a Queue Task Manager. You need to generate a list of random numbers (google how to do this); write a function that adds Add to odd numbers and replace the even numbers with Do and return a job list. The two lists look like below:

Random number list: 3,4,6,1,2,9,5,6

Job list: Task 3, Do,Do, Task 1,Do,Task 9,Task 5,Do (remember using the pattern matching and recursion; use tail recursion if possible)

Implement a Queue type that has pop and push functions.

Go through the list (remember using the pattern matching and recursion; use tail recursion if possible):

if the current element matches a Do, pop a task from the Queue and print out which task is done

else, push the new task into the Queue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students explore these related Databases questions