C++ :: How To Create A Deque Using 2 Stacks
Nov 27, 2013
I am trying to create a deque using these stacks but I failes again and again.
struct deque {
int key;
dek *next;
} *left = NULL, *right=NULL;
struct elem{
[Code] ......
View 5 Replies
ADVERTISEMENT
Apr 14, 2014
I am unable to imagine implementation of deque as it promises random access,insertion and deletion at both ends in constant time.
If a deque is implemented as vector of vectors how it can do 'random access' & 'insertion/deletion at the front' in constant time?
View 3 Replies
View Related
Dec 17, 2013
I have a question. How to find the average value of all the elements in a deque?
View 2 Replies
View Related
Apr 13, 2014
I just started by defining a stack class (stackDouble). I need to write a program that accepts an infix calculator expression, with the following operators (**, exponentiation, /, division, and, -, subtraction. The operator precedence is exponent, division, and subtraction.I need to use a stack of doubles and a stack of strings, of which I can write two classes, or write a single stack template. The user will input the expression just via cin, and there will be a # before every number, a ! before each operator, and a . at the end of the expression. '#', '!', or '.' can be input into a char variable, numbers into a double variable and operators into a string variable.
For example, the following would output 6:
# 3 ! / # 2 ! / # .5 ! ** # 2 .
As stated above, I already made up a stackDouble class. What would I need to do to create the other class (I don't think I want to do it with a template)?
Code:
#include <iostream>
#include <string>
using namespace std;
class stackDouble{
[code]....
View 2 Replies
View Related
Jan 11, 2015
How do I make a Template that has 2 stacks ?
Code:
template <class T>
class A {
};
template <class T>
class B {
};
is this code correct ?
View 1 Replies
View Related
Oct 29, 2014
As part of my hw assignment i need to reverse a string using stacks. This is my attempt and so far its not working.
// reverse.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
[Code].....
View 3 Replies
View Related
Nov 3, 2013
Given a set of different types of paired symbols; determine whether it is balanced or not (the opening and closing version of each type are paired correctly). Any other type of characters may appear in the input will be neglected.
For example:
(**(*[*])****) is balanced, also [{}**[]**()]** is balanced. But ((*{*)*}) is unbalanced as well as [()***[]***{*(*)}.
Write a C++ program that requires a string containing and expression as an input from the user and check for balanced bracket pairs using stack data structure.
Here is my code which give me nothing when I run it.
#include <iostream>
#include <string>
using namespace std;
class CustomStack {
[Code] ....
View 1 Replies
View Related
Nov 3, 2013
i feel like im really close to completing this but i cant seem to get the result printed out i dont think im calling my evaluate function correctly and its not performing the operations..
#include <iostream>
#include <stack> //stack header file
using namespace std;
[Code].....
View 1 Replies
View Related
Nov 8, 2014
How to implement the main queue functions Enque() and Deque() using two stacks S1 & S2. You allowed only to call push () and pop() functions of the two stacks to implement Enque()and Deque() functions.
#include<iostream>
using namespace std;
const int size=5;
int arr[size];
int front=-1,rear=-1;
bool isfull() {
if(rear==size-1)
[Code] .....
View 4 Replies
View Related
Mar 22, 2013
Any example of a graph search algorithm that uses a recursion and linked list based stacks to determine a route from a single point on a graph to another single point on a graph?
View 3 Replies
View Related
May 24, 2014
I need to convert from an infix expression to postfix using stacks!
#ifndef EXPRESSIONMANAGER_H_
#define EXPRESSIONMANAGER_H_
#include <iostream>
#include <stack>
#include <string>
#include <sstream>
using namespace std;
class ExpressionManager : public ExpressionManagerInterface{
[code]....
View 2 Replies
View Related
Nov 22, 2012
I am still new to stacks and recursion and am trying to implement two functions using recursion to get the maximum element in a stack and copying one stack into the other but it keeps repeating some elements and i dont understand why!!
this is the code for the functions:
void copyStack(MyStack &firstStack, MyStack &secondStack) {
if(!firstStack.empty()) {
string x=firstStack.top();
firstStack.pop();
//secondStack.push(x);
[Code] ....
View 2 Replies
View Related
Oct 21, 2014
The question is to write a recursive boolean function that compares two stacks and returns true if they are identical. This is where I get stuck:
If the top items of both stacks are the same, the recursive call always returns true, because 'true' is saved on top of the return stack.
Here is my code:
template<class Type>
bool identicals(stackType<Type> s1, stackType<Type> s2) {
if(!s1.isEmptyStack() && !s2.isEmptyStack()) {
if(s1.top() != s2.top())
[Code] ....
View 2 Replies
View Related
Sep 28, 2014
I was given a task to convert infix to post fix using both linked lists and stacks in the code so this is what i have written but the problem is it is giving me same error at three different places "missing function header(old style format?)
#include <iostream>
#include <string>
using namespace std;
const int size = 100;
class stack{
private: // Declare a structure for the list
[Code] ....
View 12 Replies
View Related
Oct 26, 2013
I have a struct called Array and I'm to create a function to create a dynamic array that's fill with randomly generated integers from 0 to 50 (inclusive) and a function to destroy the array for freeing its memory. Below the code that I have written so far.
Code:
* Struct */
typedef struct {int *pArray; //the dynamic array
int length; //the size of the dynamic array}Array;
/* Function to create a dynamic array */
Array *initializeArray (int length) {int i;
}
[code]....
View 7 Replies
View Related
Apr 10, 2014
I need to create a project that create a automated backup of a file.
i will get the file from C:/Folder/file.exe and move for a other created folder, but.. in every time that user make this backup, a folder will be created with year, month and date, like: C/Folder2/2014/April/16:42/file.exe.
View 4 Replies
View Related
Feb 10, 2013
For my data-structures class, I am attempting to create a binary search tree template to be used to create an AVL tree. I've written a Generic_Tree template for the BST to inherit from, and before I jump into implementing the AVL tree I'm testing the BST member functions. Everything was compiling fine until I added the BST insert() function. Now, I'm getting the following error message from my linker:
undefined reference to 'BST<void>::insert(int, void*)'
Stemming from the call in main line 16.
my makefile compiles with:
g++ -Wall -g Generic_Tree.cpp BST.cpp barfing.cpp main.cpp
Generic_Tree:
template < typename NODE_DATA, unsigned MAX_KIDS >
class Tree {
protected:
struct NODE {
NODE_DATA* contents;
Tree* child[MAX_KIDS];
Tree* parent;
[Code] ....
I'm use to c and havn't used classes or templates before (except for declaring instances of them). The whole syntax is mystifying to me,.
View 4 Replies
View Related
Oct 23, 2013
I've been programming for a while but. I've never made or used a DLL before.
Edit: In eclipse.
View 2 Replies
View Related
Oct 31, 2013
I have an assignment that asks me to implement a variant of the classic bouncing balls program.
'Each ball should start off at the top of the screen with a random speed in the x direction. Whenever a ball hits a screen boundary it should bounce off at an angle equal to the impact angle and lose some speed. Eventually each ball should come to a rest at the bottom of the screen. Five seconds after coming to a rest a ball should be removed from the screen.'
'Your code must keep track of objects (balls) by placing the object data structures in a linked list. You need to create your own linked list implementation. Below is a brief description of the object programming interface: CreateObject - Create a new object. The function accepts as input parameters a pointer to the SDL screen, a pointer to a model triangle array, and a variable telling the size of the model triangle array. The function returns a pointer to a new object data structure. The model triangle array specified as input parameter should not be shared across objects. (Not sharing the model triangle array allows e.g. objects to have different colors.)
Perform the necessary memory allocation and copying.DestroyObject - Free object. The function accepts as input parameters a pointer to an object data structure. The function should free all memory allocated to represent the object (memory allocated for the model triangle array and the object data structure itself).
Drawobject - Draw object on screen. The function accepts as input parameters a pointer to an object data structure. The function must draw the object on the screen by calling DrawTriangle on each of the model triangles. Remember to update scale, translation, etc., in each triangle data structure before invoking DrawTriangle.
Hint: Do not make the bouncing algorithm too complex. Bouncing a ball off a vertical or horizontal surface can be accomplished without resorting to calculating impact angles.'
The function I'm stuck at, is the first one - createobject.
My first aim is to get one ball on the screen.
Code:
// Create new object
object_t *CreateObject(SDL_Surface *screen, triangle_t *model, int numtriangles)
{
object_t *object = malloc(sizeof(object_t));
object->model = malloc(sizeof(sphere_model));
object->screen = SDL_Surface;
memcpy(*model, object->model, sizeof(object_t));
return object;
// Implement me
}
This is what I've done so far.
View 4 Replies
View Related
Dec 1, 2013
I am trying to create a box outside my 9x9 array. However, my box did not cover up everything.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <conio.h>
#define row 19
#define col 19
[Code] ....
View 6 Replies
View Related
May 11, 2014
I need to create a UML class diagram for this code
private:
GradedActivity *grades[NUM_GRADES];
public:
void setLab(GradedActivity *activity)
{ grades[LAB] = activity; }
View 1 Replies
View Related
Jan 24, 2014
#include<iostream.h>
#include<time.h>
#include<conio.h>
[Code].....
View 3 Replies
View Related
Feb 28, 2013
I'm trying to make a database that stores the information without overwrite it. I want this program to store the client’s selection in somewhere that doesn't change and also that creates a new storage for the new value any time the client enters a new selection instead of overwriting it. I did something like that in my code but any time the program runs again and the client enters a new selection, the client’s selection is overwritten with the new value. I don’t know if it’s possible to do that (store the client’s selection in somewhere where doesn't change) with C++. I've been reading and I think I can create a database for my program.
THIS IS MY CODE:
#include <iostream>
#include <string>
using namespace std;
// FUNCTIONS
[Code]...
View 2 Replies
View Related
Nov 21, 2013
I'm trying to find out how to create and use DLL's in eclipse.
I know general C++, library but i cannot figure out DLL's.
View 1 Replies
View Related
Oct 21, 2014
How to create a folder in mfc ..
View 1 Replies
View Related
Aug 28, 2014
I am trying to create a OCX from a C++ dll., Here's the scenario I have a C++ dll and this dll needs to be called in VB.net program my boss want's me to create an OCX out of this.
C++ dll and use it in a VB.net class library, apparently I have created an OCX but it requires a form but the VB.net program is a class library.
View 5 Replies
View Related