Write several functions to perform operations on the queue

Assignment Help Python Programming
Reference no: EM132356477

Question

A queue is a data structure use to store items. The next item removed from a queue is always the item that has been in the queue the longest (i.e., was added first - think of a line of people waiting to buy something). In this question, you will use a list to implement a queue and write several functions to perform operations on the queue. For this question, you may not use classes and/or object-oriented programming in your solution. Your program will need the following components:

1. A variable representing the maximum size of the queue (how many items can be stored in the queue at one time). This value should have a default value of 10.

2. A list type variable, which is used to store all of the data in the queue.

3. An enqueue function, which takes a single input value. If there is room in the queue (i.e., the current size is less than the maximum size), the value will be added to the end of the queue and the function will return True. If there is no room in the queue, the function will return False.

4. A dequeue function, which has no inputs. If the queue has any items in it, this function will remove and return the first item (i.e., from the front of the queue). If the queue does not have any items in it, the function should return None. In this case, None is the specific Python value representing nothing, not the string value "None".

5. A peek function, which has no inputs. If the queue has any items in it, this function will return the value of the first item in the queue but leave that item in the queue (different from the dequeue function). If the queue does not have any items in it, the function should return None. In this case, None is the specific Python value representing nothing, not the string value "None".

6. An isempty function, which takes no inputs. This function should return True if the queue is empty (no items) and False otherwise.

7. A getlist function, which has no inputs. This function will return the list that stores the queue data. This function can be used to print the queue contents using print(getlist()).

8. A multienqueue function, which takes a single list type input argument. This function should add as many of the items from the input list to the queue (i.e., keep adding until the queue is full or all items have been added) and return the number of items that were added successfully.

9. A multidequeue function, which takes a single integer input value N. This function should attempt to dequeue up to N items from the queue and return a new list containing all items removed (note: this may be less than N if the queue has become empty).

Reference no: EM132356477

Questions Cloud

Describe teacher leadership and its importance : Using current literature as your foundation, describe "teacher leadership" and its importance to collaboration in the school. Provide specific examples.
Which stakeholders identify academic or behavioral concerns : Which stakeholders can identify academic or behavioral concerns? Why? What information can be shared with stakeholders outside of the IEP team regarding.
Complete business activity and instalment activity statement : FNSTPB401 - Complete business activity and instalment activity statements - Certificate IV of Accounting and Book-Keeping - Sydney City College of Management
How do you involve parents in the special education process : How do you involve parents in the special education process? What support do you offer parents of individuals with disabilities?
Write several functions to perform operations on the queue : You will use a list to implement a queue and write several functions to perform operations on the queue. A queue is a data structure use to store items.
How do word recognition and print concept relate to fluency : How do word recognition, phonemic awareness, and print concepts each relate to fluency? What is the importance of scaffolding in teaching these concepts.
What you know about brain functions in process of learning : Brain-based teaching and learning is a new paradigm of pedagogy. It is one of the most exciting fields in the world of brain research, based on research.
Explanation of systematic risk-potential return associated : Discuss diversification strategies for your portfolio. Brief explanation of the systematic risk and potential return associated with that particular investment.
Discuss the process of working memory : Our working memory is a significant component to learning new information. Working memory is complex as it encompasses many areas of the brain.

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd