Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi pls help with question 3 and 4 Exercise 3 Write an iterator for a Circular Queue, that iterates through all the items in the

Hi pls help with question 3 and 4

image text in transcribed

Exercise 3 Write an iterator for a Circular Queue, that iterates through all the items in the queue from front to rear Exercise 4 Consider an List class that defines a list data type with the following methods __init__(self) iter__(self) # for instance creation via List() # returning an instance of Iterator via iter() where Iterator is an iterator class of List that provides the method __next__(self) # for accessing the next item via next() (a) Define a method appears(alist, item, k) where k is an integer and appears returns True if the item appears at least k times in alist. For example, given a list with elements 8, 7, 6,7, 89, 6, 5, 3, 6, 100, where element 8 is the head, a call to appears (a list, 6, 3) would return True, while a call to appears (a list, 6, 4) would return False. IMPORTANT: the implementation should be such that you stop as soon as you know the answer is True (b) What is the best/worst Big O complexity for a list of N elements? Explain. Exercise 3 Write an iterator for a Circular Queue, that iterates through all the items in the queue from front to rear Exercise 4 Consider an List class that defines a list data type with the following methods __init__(self) iter__(self) # for instance creation via List() # returning an instance of Iterator via iter() where Iterator is an iterator class of List that provides the method __next__(self) # for accessing the next item via next() (a) Define a method appears(alist, item, k) where k is an integer and appears returns True if the item appears at least k times in alist. For example, given a list with elements 8, 7, 6,7, 89, 6, 5, 3, 6, 100, where element 8 is the head, a call to appears (a list, 6, 3) would return True, while a call to appears (a list, 6, 4) would return False. IMPORTANT: the implementation should be such that you stop as soon as you know the answer is True (b) What is the best/worst Big O complexity for a list of N elements? Explain

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago