TAB

One of the works done by our Robotics and Machine Learning division,
SELF-LEVELING QUADCOPTER
Arduino based Quadcopter.
Self-leveling is acheived by the aligning the quadcopter using the readings from the gryo as well as the accelerometer.
A four channel RC transmitter is used to control the movement of the quadcopter when in flight. Kindly subscribe to our YouTube Channel and stay tuned.

Friday 12 February 2016

PRACTICE PROBLEM 3 : (11-2 to 17-2) : Tender scrutiny using refferrence variable


#include<iostream>
using namespace std;
class vendor
{
long r;
string name;
public:
long v;
void read()
{
cin>>r;
cin>>name;
cin>>v;
}
void display()
{
cout<<r<<endl;
cout<<name<<endl;
}
};
vendor * search(vendor * V,int n);
vendor * search(vendor * V,int n)
{
long min=V->v;
vendor * A;
A=V;
for(int i=0;i<n;i++)
{
if(min>V->v)
{
min=V->v;
A=V;
}
V++;
}
return A;

}
int main()
{
int n;
cin>>n;
vendor V[n];
for(int i=0;i<n;i++)
{
V[i].read();
}
vendor * MINV=search(&V[0],n);
MINV->display();


return 0;
}

7 comments:

  1. do you any idea what kind of question will come in skillrack for Data Structures and Algorithms

    ReplyDelete
  2. It should initially be plain implementation of the datastructures(stack,queue,BT etc) in the form of a problem!

    ReplyDelete
  3. Could you just give a tiny explanation of what exactly happens in the search function? Thank you!

    ReplyDelete
    Replies
    1. 1) I assign the minimum value as the first value
      2)Create n object pointer (A) to store reference to the object with minimum tender value.
      3)the for loop iterates through the array of objects to check if it's value is less than the minimum value, if so updation occurs. (A becomes the current object)
      4) Note that here no objects are directly used. We use references, as the question demands it. ('->' operator is used to access the members of an object pointer) ('.' will not work here)

      Delete
  4. Could you give a short explanation of what happens inside the search function? Thank you!

    ReplyDelete
  5. Could you please let us know how to write the pseudocode when class is there in a program? Thanks a lot!

    ReplyDelete
    Replies
    1. We will mostly use a UML diagram using 'dia' rather than a pseudocode for problems involving a class

      Delete