|
Hi!
I'm a fellow that has big problems on starting this next datastructure lab in c++ . I have so much in my mind right now and I don't know if I'm gonna complete this lab on time.
So i'm wondering if there are someone that could help me with this lab?
We use at the school visual studio 6.0
Here's the lab description:
A) Hash table
Now your going to make an article-storage were the articles will be saved in a hash-table for fast prompt accessible. For every article saves the information of the article-number, article-type and the amount articles in the storage.
You should be able to “hash” on the article-number( i.e article-number is the key). You should be able to ADD, SEEK and LIST the articles in the storage.
The programme shall handle collision with "Separate Chaining” i.e create linked list at collisions. You shall therefore make an array of pointers that initiate to NULL, afterward you should be able to seek and add articles that are missing.
At collision you do your linked list. Use here as said a linked list and a string class.
Remember when you add an article for the first time to the index, you have to move the NULL-pointer to point at the new post and then link the article last in the list.
If an article with that article-number already exist in the list, the numbers on the storage should increase on the one that already existed.
Does’nt the articlename correspond, then you could yourself decide how it’s gonna be solved in your programme.
Assume from these files(must use)
1. Hash.h
2. Hash.cpp
3. Article.h
B) Sorting
This task goes out on that you have to implement 3 optional sorting-algorithms. The algorithms shall be choosed so an algorithm works with O(n2), next with O(n log n) and the last one with O(n).
Write a programme that at random takes number-values to a file. This file shall be used as indata for sorting. After the sorting, shall the result be written out into a result-file. The result-file shall also be used as indata for sorting, to see how the algorithms works on the already sorted or almost sorted data ( if some values changes).
You shall have to create data-files with 5 different quantity of numbers to sort. These values shall be used as indata to respective algorithm. Run the algorithm with indata that is both sorted and unsorted.
You shall use these following numbers: 100 000, 200 000, 400 000, 800 000 and 1 600 000 values. Same computer must be used to check all values to have a more fair result and the computer may not work with other things during the process of the sorting.
Is it so that your computer makes the sorting too quick or too slow, you may have to change some numbers so you get a better result, NOTE that the quantity of the numbers shall double for each sorting.
Every algorithm shall have two variables, compare and swap, that counts how many comparision and copies of values has been made during the sort. These two variables shall be used in comparision between the different algorithms.
Registrate also the time the algorithms take when they are used, by using following class:
1. Timer.h
2. Timer.cpp
Do a table with your results that contains these facts:
• Run with an unsorted and a sorted data
• Values for compare and swap for respective run
• Time-consumption for respective run
Here comes the code for the following files.
1. Hash.h
<br />
#ifndef _HASH_H<br />
#define _HASH_H<br />
<br />
#include "LinkedList.h"<br />
<br />
class Hash<br />
{<br />
public:<br />
Hash();<br />
~Hash();<br />
<br />
private: <br />
const int TABLESIZE;<br />
LinkedList *m_table;<br />
};<br />
<br />
#endif<br />
2. Hash.cpp
<br />
#include "Hash.h"<br />
<br />
Hash::Hash() : TABLESIZE(11)<br />
{<br />
m_table = new LinkedList[TABLESIZE];<br />
}<br />
<br />
Hash::~Hash()<br />
{<br />
delete[] m_table;<br />
}<br />
3. Article.h
<br />
#ifndef _ARTICLE_H<br />
#define _ARTICLE_H<br />
<br />
#include "String.h"<br />
<br />
class Article<br />
{<br />
public: <br />
Article(int i_key, int i_number, String i_type);<br />
<br />
private:<br />
int m_key;<br />
int m_number;<br />
String m_type;
}; <br />
<br />
#endif<br />
4. Timer.h
<br />
#ifndef TIMER_H<br />
#define TIMER_H<br />
<br />
class Timer<br />
{<br />
public:<br />
Timer(){ m_startTime = 0; m_stopTime = 0; }<br />
int startTimer();
double stopTimer();
<br />
double getTime();
private:<br />
<br />
double m_startTime;<br />
double m_stopTime;<br />
double m_frequence;<br />
};<br />
<br />
#endif<br />
5. Timer.cpp
<br />
<br />
#include <windows.h><br />
#include "timer.h"<br />
<br />
<br />
int Timer::startTimer()<br />
{<br />
LARGE_INTEGER start, freq;<br />
if(!QueryPerformanceFrequency(&freq))<br />
return 0;<br />
m_frequence = (double) freq.QuadPart;<br />
QueryPerformanceCounter(&start);<br />
m_startTime = (double)start.QuadPart;<br />
return 1;<br />
}<br />
<br />
double Timer::stopTimer()<br />
{<br />
LARGE_INTEGER end;<br />
QueryPerformanceCounter(&end);<br />
<br />
m_stopTime = (double)end.QuadPart;<br />
<br />
return (m_stopTime-m_startTime) * 1000.0 / m_frequence;<br />
}<br />
<br />
double Timer::getTime()<br />
{<br />
return (m_stopTime-m_startTime) * 1000.0 / m_frequence;<br />
}<br />
That's all. You can send me the programme by mail if you finished the lab. That would be awesome!
THANK U ALL!
|
|
|
|
|
El_Maco wrote:
You can send me the programme by mail if you finished the lab.
I don't think you're going to get any takers here. If you have a specific problem or question, we'd be happy to help you.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
No problem.
Please give me the contact number for your schools acidemic dishonesty board. Somethings they have a different name, whoever the group is that investigates cheating.
|
|
|
|
|
Hi, ALl
I am having a problem with a Printer running on Window XP... The computer would run into BLUE SCREEN during shutting down if the Printer had been turned before shutdown?
One solution is to uload or stop the printer driver before shutdown.
My questions are:
1) how to write a program that can stop or unload the printer driver?
2) how to let XP automatically unload the driver instead of manually just before shutdown?
Your help and contribution appreciated!
JW
DJ
|
|
|
|
|
hi everybody,
can anybody give me a link or resource that might show how to draw large graphics more fast just like Microsoft MapPoint and illustrator??
thanks.
abel.
|
|
|
|
|
Use Direct Draw that is fastest way to draw something.
Make a surface in VGA memory,get the pointer of it, write any thing whatever you want.
If you don't know anything about DX. just make a memDC and write something there and blt it.
|
|
|
|
|
I'm creating a program to move a robotic arm with six axis. For each axis I have three pushbuttons. I'll use the rotate main arm for an example. The main arm has a left, right and stop pushbuttons. This works fine as it is, but I would like to limit this to two pushbuttons (left and right). Is there a way that I can press the left or right button so that when pressed it moves in the direction being pressed or stops when released? Right now each button has a funtion. The left button is OnLeft(). Inside this function the code to move the arm to the left is _outp(0X302,0X08). All the other buttons are similiar for each axis.
Thanks,
jfletcher
|
|
|
|
|
Hello,
You can try to subclass the button control and override OnLButtonDown() and OnRButtonDown()...
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
change in the AFX_MESSAGE_MAP the message associated to your button from WM_COMMAND to WM_LBUTTONDOWN
TOXCCT >>> GEII power
|
|
|
|
|
Dear .NET Developers,
I need to do a report like Master Detail.For Example two reports are there test and test1.If I click the report test,test1 report should come.Is it possible to do like this.Help me.
radha
|
|
|
|
|
Hi,
I am getting the ERROR_ALREADY_EXISTS error when I call WaitForMultipleObjects(). Any idea why this is happening?
Thanks.
|
|
|
|
|
Hello,
According to MSDN, WaitForMultipleObjects() does not return that value???
Can you post the code that is causing that error?
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
Hi,
Thanks for responding. Yes, that is right. WaitForMultipleObjects() returns a WAIT_FAILED(-1). When I get this I do a GetLastError() and that is when I get the ERROR_ALREADY_EXISTS(183) error.
Thanks!
|
|
|
|
|
Hi,
I am creating a training tool to demonstrate software crashes. My tool will demonstrate a runtime error, GPF (General Protection Fault) and a BSOD (Blue Screen of Death). So far my utility can create the first two scenarios but not the last, the BSOD. Does anyone have an example of code that will create this situation? I have tried Multi Threading with forced shutdown and accessing the kernel32.dll and I either get a GPF or the system shutsdown, with no BSOD. I can create dummy screen shots of a BSOD but for training purposes I would like to create the real thing so I can use WinDBG to analyze the memory dump file.
-Venny
|
|
|
|
|
|
I have a dialog app.
i work with a menu:
CMenu * menu = this->GetMenu();
menu->CheckMenuItem(ID_XXX, MF_BYCOMMAND | MF_CHECKED);
and so,so. - and i have a boolean variable that i modify on each click.
Then i have to hide the menu. SetMenu(NULL). Then when i load it again,now it executes all the commands, but it does not check or uncheck any items... what could i do ?
Thanks.
|
|
|
|
|
This is a working example:
CMenu m_menu;
BOOL CYourDlg::OnInitDialog()
{
...
m_menu.LoadMenu(IDR_MENU1);
SetMenu(&m_menu);
...
}
void CYourDlg::OnMenuXXXCommand()
{
CMenu * menu = GetMenu();
if(menu)
{
CMenu* pPopup = menu->GetSubMenu(0);
if(pPopup->GetMenuState(ID_XXX,MF_BYCOMMAND)&MF_CHECKED)
pPopup->CheckMenuItem(ID_XXX, MF_BYCOMMAND | MF_UNCHECKED);
else
pPopup->CheckMenuItem(ID_XXX, MF_BYCOMMAND | MF_CHECKED);
}
void CYourDlg::OnButtonClick()
{
if(GetMenu())
SetMenu(NULL);
else
SetMenu(&m_menu);
}
Regards,
Andrzej Markowski
|
|
|
|
|
I am working on a voip application where a hardware say board with its own channel configured
are to be used.
I am making a cli (cmd line interface) which accepts only a proper syntax.
If teh syntax z found correct. ..it connect itself to the board and does as reqd.
To further illustrate, if the cmd comes like :
" Open Channel <y>, Dial the destination number xxxxx ,Play a file "WelcomeMsg.pcm"It should open a particular channel ,dial the number and on getting connected,it shud play the file.
I ve my cli n the board ready.
But i fail to connect the 2.
I suppose, I shud take the board as my server and connect the cli(client) thru a socket.
This cli application has 2 be on multi wrkstations all connecting to board.
If u understood my question cud u plz oblige with a clarification n assure if i m going right path.
amit mishra
|
|
|
|
|
I have to do a program that reads from a file and copies that text file to a new one and time how long the process takes to do so. The program copies the files correctly but does not display the time correctly. I will show the entire code since it is pretty small. Right now the duration is equal to finish time - start time / CLOCKS_PER_SEC. The output will say
The process took 1202590843 seconds to complete, but when i step through it and put a watch on duration it shows the correct time like 11.567000000
#include <iostream.h><br />
#include <windows.h><br />
#include <stdio.h><br />
#include <time.h><br />
<br />
#define BUFFER_LEN 200 // # of bytes to read/write<br />
<br />
<br />
void main(int argc, char *argv[]) <br />
{<br />
clock_t start,finish;<br />
double duration;<br />
<br />
char buffer[BUFFER_LEN + 1];<br />
<br />
DWORD dwShareMode = 0;
LPSECURITY_ATTRIBUTES lpFileSecurityAttributes = NULL;
HANDLE hTemplateFile = NULL;
<br />
<br />
HANDLE sourceFile;
DWORD numberOfBytesRead;<br />
LPOVERLAPPED lpOverlapped = NULL;
<br />
HANDLE sinkFile; <br />
DWORD numberOfBytesWritten;<br />
<br />
start=clock();
<br />
sourceFile = CreateFile (<br />
"C://Constitution.txt",<br />
GENERIC_READ,<br />
dwShareMode,<br />
lpFileSecurityAttributes,<br />
OPEN_ALWAYS,<br />
FILE_ATTRIBUTE_READONLY,<br />
hTemplateFile<br />
);<br />
<br />
if(sourceFile == INVALID_HANDLE_VALUE) <br />
{<br />
fprintf(stderr, "File Open operation failed\n");<br />
ExitProcess(1);<br />
}<br />
<br />
sinkFile = CreateFile (<br />
"C://NewVersionConstitution.txt",<br />
GENERIC_WRITE,<br />
dwShareMode,<br />
lpFileSecurityAttributes,<br />
CREATE_ALWAYS,<br />
FILE_ATTRIBUTE_NORMAL,<br />
hTemplateFile<br />
);<br />
<br />
if(sinkFile == INVALID_HANDLE_VALUE) <br />
{<br />
fprintf(stderr, "File Open operation failed\n");<br />
ExitProcess(1);<br />
}<br />
<br />
while<br />
(<br />
ReadFile(<br />
sourceFile, buffer,<br />
BUFFER_LEN, &numberOfBytesRead,<br />
lpOverlapped<br />
)<br />
&&<br />
numberOfBytesRead > 0<br />
) <br />
{<br />
WriteFile(sinkFile, buffer, BUFFER_LEN,<br />
&numberOfBytesWritten, lpOverlapped);<br />
}<br />
<br />
CloseHandle(sourceFile);<br />
CloseHandle(sinkFile);<br />
<br />
finish=clock();
duration=(double)(finish-start) / CLOCKS_PER_SEC;<br />
printf("The process took %d ",duration);<br />
printf("seconds to complete\n");<br />
<br />
ExitProcess(0);<br />
<br />
}
|
|
|
|
|
%d in printf is for int's etc. not doubles. Have a look at the format spec for printf and see what to use for doubles. Might be %f but you need to check.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Yes that was it, thanks a lot!
|
|
|
|
|
The program now outputs duration however, this is something I dont understand.
If I run the program normally, meaning without debugging(stepping through it) it says the process takes 0.08000 seconds but if I insert a breakpoint when the file is closing and debug it, it will say the process takes 24.795 secs to do.
When I was debugging I put a watch on duration and that was the 24.795 was the correct output. If I run it without the debugging it says 0.08. How or why does debugging change the value of the variable duration?
|
|
|
|
|
Hi!
How can I get the path (read: executable file) to the default browser for http:// links?
I tried to get the .htm key in the registry, but this isn't the default browser for http:// links. And no, I cannot just use ShellExecute, I really need the executable file.
Any ideas??
Thanks and best regards,
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
|
Its not on win2k nor win 2003 ;/
|
|
|
|