Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

1. Create the following ADTs.

(a) Write the constructor function makestk, predicate function emptystk and mutator functions pushstk and popstk:

i. makestk returns a new stack in the form of a tagged tuple: ('stack',[]).

e.g. >>> cellstk=makestk()

>>> cellstk

('stack', [])

ii. emptystk returns True or False depending on whether the given stack is empty or not.

e.g. >>> emptystk(cellstk)

True

iii. pushstk accepts a stack and an element, and adds the element to the stack at position 0 (see part (b) below for the creation of cell0).

e.g. >>> pushstk(cellstk,cell0)

>>> cellstk

('stack', [('cell', (0, 0), ['t', 'b', 'r', 'l'])])

iv. popstk removes the element at position 0 of the given stack.

e.g. >>> popstk(cellstk)

('cell', (0, 0), ['t', 'b', 'r', 'l'])

>>> cellstk

('stack', [])

(b) Write a constructor function called makecell, accessor functions getx, gety and getwalls, and mutator functions removetw, removebw, removerw, removelw.

i. makecell accepts a tuple which consists of the x and y co-ordinate of the cell being created. It returns a cell in the form of a tagged tuple:

('cell',(x,y),['t','b','r','l']).

The list represents the four walls of the cell: top, bottom, right and left.

e.g. >>> cell0=makecell((0,0))

>>> cell0

('cell', (0, 0), ['t', 'b', 'r', 'l'])

ii. getx and gety return the x and y co-ordinates (respectively) of a given cell.

e.g. >>> getx(cell0)

0

iii. getwalls returns the list of walls that are intact for a given cell

e.g. >>> getwalls(cell0)

['t', 'b', 'r', 'l']

iv. remove?w removes the associated wall from the list of walls of a given cell.

e.g. >>> removetw(cell0)

>>> cell0

('cell', (0, 0), ['b', 'r', 'l'])

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9526000

Have any Question?


Related Questions in Computer Engineering

Explain that when an unauthorized individual gains access

Explain that when an unauthorized individual gains access to the information an organization trying to protect, that act is categorized as a deliberate act of espionage or trespass.

What are some skills individuals who work in the field of

What are some skills individuals who work in the field of cyber security need to prevent hacks in to a company's computers?

What are the best practices to follow for microsoft windows

What are the best practices to follow for Microsoft Windows network security. Which two would you start with and why?

Explain the two real world examples of database what are

Explain the two real world examples of database. What are they? How do people use them? Discuss at least one situation that would arise from problems in these database, such as redundant information, breach of informatio ...

Need help with the following 2 problems1 they offer you a

Need help with the following 2 problems: 1. They offer you a promissory note with a four-year maturity, which will generate $ 3,000 at the end of each of the four years. Its price is $ 10,200. What is the implicit annual ...

Are there manufacturers and retailers who have taken steps

Are there manufacturers and retailers who have taken steps to reduce their pollution impact, both air quality and industrial pollution, while maintaining a viable place in the market?

This is a chemistry question regarding physical and

This is a chemistry question regarding physical and chemical changes. The question is the following: You mix 3 liquids and the resulting solution becomes very hot. A short time later bubbles began to form. There is a che ...

Question ransomware to pay or not to pay when it comes to

Question: Ransomware: To pay or not to pay? When it comes to corporate data, should corporations pay? Can you trust paying? What can be done to protect against ransomware?Would you pay if it were your own personal data? ...

Right now the following information is in the header file c

RIght now, the following information is in the header file (C language). # ifndef ArrayBagStack # define ArrayBagStack # define TYPE int # define EQ(a, b) (a == b) struct arrayBagStack { TYPE data [100]; int count; }; Qu ...

What are the critical issues we must think about while

What are the Critical Issues we must think about while designing a Lexical Scanner? The results of that development, e.g., discuss both process and product.

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As