Data Structures and Algorithm Related Question - Th...
Data Structures and Algorithm Related Question - Th...
com
home / study / engineering / computer science / computer science questions and answers / data structures and algorithm related question: there is a …
at one
time. The garage is built in such a way that only the last truck
entered can be moved
a) On_road (truck_id);
c) Exit_garage (truck_id);
Expert Answer
(Answer):-
#include <iostream>
class Truck
private:
int id;
public :
Truck(int id)
this->id=id;
Truck()
this->id=0;
int getid()
return id;
};
int onRoad(Truck t_id) // will tell if the truck t_id is at the gate of the garage or not
if(garage[top].getid()==t_id.getid())
return 1;
else
return 0;
void enter_Garage(Truck t) {
if(top>=n-1)
else {
top++;
garage[top]=t;
void exit_Garage(Truck t) {
if(top<=-1)
else {
if(onRoad(t)==1)
top--;
else
void show_Trucks() {
if(top>=0) {
cout<<endl;
} else
cout<<"\nGarage is empty";
int main() {
Truck t1(2);
Truck t2(4);
Truck t3(6);
Truck t4;
enter_Garage(t1);
enter_Garage(t2);
enter_Garage(t3);
enter_Garage(t4);
show_Trucks();
exit_Garage(t1);
exit_Garage(t4);
show_Trucks();
Comment
Q: 6. Calculate the Grashof condition of the fourbar mechanisms defined below. Draw clear diagrams of the linkages and
describe the motions of each inversion. a. 2 4.5 7 9 b. 2 4.0 6 8 C. 2 3.5 7 9
A: See answer
COMPANY LEGAL & POLICIES CHEGG PRODUCTS AND SERVICES CHEGG NETWORK CUSTOMER SERVICE
About Chegg Advertising Choices Cheap Textbooks Chegg Math Solver EasyBib Customer Service
Chegg For Good Cookie Notice Chegg Coupon Mobile Apps Internships.com Give Us Feedback
College Marketing General Policies Chegg Play Sell Textbooks Thinkful Manage Subscription
Corporate Development Intellectual Property Rights Chegg Study Help Solutions Manual
Investor Relations Terms of Use College Textbooks Study 101
Jobs Global Privacy Policy eTextbooks Textbook Rental
Join Our Affiliate Program DO NOT SELL MY INFO Flashcards Used Textbooks
Media Center Honor Code Learn Digital Access Codes
Site Map Honor Shield Uversity Chegg Life
Chegg Writing
https://www.chegg.com/homework-help/questions-and-answers/data-structures-algorithm-related-question-garage-access-road-accommodate-number-trucks-on-q92205241?trackid=f940a43955b6&strackid=f9b92c8fa929 1/1