|
I have seen that almost data structure I known so far does DeleteMinimum in O(log N) in worse case. but no algorithms can do this in O(1).
Welcome to my site:
http://www.cntomorrow.com:3310
|
|
|
|
|
If the data structure is sorted, then you could achieve O(N) for deletion.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
I think you will find that Insert in constant time and DeleteMinimum in constant time are mutually exclusive.
An unsorted linked list (or even a vector) will allow for Insert to occur in constant time (just add the new element to the end of the list), but DeleteMinimum would require a search to find the value and could not be done in constant time.
On the other hand a sorted linked list would let you perform DeleteMinimum in constant time (because you know the minimum value will always be the first [or last] element of the list). Insert into the sorted list, however, could not be done in constant time since you would have to determine where in the list to place a new entry.
So, you have a trade off. Do you want Insert to be efficient or DeleteMinimum to be efficient? You need to understand how an application will use data in order to choose the optimum data structure.
Regards,
Dan
Remember kids, we're trained professionals. Don't try this at home!
|
|
|
|
|
Thanks, Dan McCormick. Thank you very much!
Welcome to my site:
http://www.cntomorrow.com:3310
|
|
|
|
|
How can we enable an edit box after a button is clicked??
By using fprintf function, how can we print the character backslash (/) and aphostrophy (') in a .txt file???
HelpMe, I like your help
|
|
|
|
|
beardy janggut wrote: How can we enable an edit box after a button is clicked??
m_your_edit.EnableWindow(TRUE);
beardy janggut wrote: By using fprintf function, how can we print the character backslash (/) and aphostrophy (') in a .txt file???
The one you are showing is forward slash. You can print it by including it in the string.
For backslash you have to give two of them together '\\'. This will print a backslash character.
' can be printed as usual.
Nibu thomas
Software Developer
|
|
|
|
|
beardy janggut wrote: How can we enable an edit box after a button is clicked??
On handller of Button:-
GetDlgItem(ID_OF_BUTTON)->EnableWindow(TRUE);
|
|
|
|
|
Hi there..
Anybody knows a way (if it is even possible) to determine an array's size. Something like this:
int GetSize( int* pArray )
{
}
int main( void )
{
int* pArray;
pArray = new int[ 20 ];
printf( "%d\n", GetSize( pArray ) * sizeof( int ) );
return 0;
}
regards [[]]
hint_54
|
|
|
|
|
You can determine the number of elements in a staticly-allocated array:
#define countof(x) (sizeof(x)/sizeof((x)[0]))
int arr[10];
size_t cElements = countof(arr); You cannot do this in a function, however, it's just not possible in C. That's why a function always takes an array (or pointer) and a count of elements when it has to know the array's size.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Michael Dunn wrote: That's why a function always takes an array (or pointer) and a count of elements when it has to know the array's size.
Could be speed optimization
Too bad.. I'll just have to do that
regards
hint_54
|
|
|
|
|
Once you pass the array to the function it decays to pointer and size information is lost. Why not use a std::vector instead?
Steve
|
|
|
|
|
Stephen Hewitt wrote: Why not use a std::vector instead?
std::vector is one of best solution for dynamic array i believe... But ones should know how to deal with raw one too.. then he can able to differntiate what is good and what is bad!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
If your array was created in heap, just like your code above, then you can use the function _msize to determine the size (in bytes) of your array.
int GetSize( int* pArray ){<br />
return _msize((void *) pArray / sizeof(int));<br />
}
but if your array was created in stack, _msize does work properly.
Regards.
Welcome to my site:
http://www.cntomorrow.com:3310
|
|
|
|
|
the code should be:
int GetSize( int* pArray ){
return _msize((void *) pArray) / sizeof(int);
}
Good luck.
Welcome to my site:
http://www.cntomorrow.com:3310
|
|
|
|
|
Pointers and operator new... :'( Stack...
Thx
regards
hint_54
|
|
|
|
|
Hello,everyone.I want to programming DirectX in VC6,so what shoul I install in my computer to support DirectX programming?Where is the DirectX SDK download address?
|
|
|
|
|
Hi,
I'm trying to figure out how to implement a way where I could switch my user interface captions from English to another language (Ex. Dutch). It does not have to be switchable during runtime, but if a flag for the language could be defined in a config file read during initalization and based on that I would like to display the respective captions. Any help would be greatly appericated.
Thanks
|
|
|
|
|
google for "Resource DLL"
in short, you create a duplicate of your resources that you translate, and load them when your application starts.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Close button is at top-right corner of a Dialog, which is used for closing the dialog.
I want to disable the button - but keep Min and Max buttons valid.
Is this possible? how to do it?
A nice tool for optimizing your Microsoft html-help contents.
Includeh10
|
|
|
|
|
Removing close from system menu will do it...
CMenu* pSysMenu = GetSystemMenu(FALSE);
pSysMenu->RemoveMenu(SC_CLOSE, MF_BYCOMMAND);
Nibu thomas
Software Developer
|
|
|
|
|
includeh10 wrote: Close button is at top-right corner of a Dialog, which is used for closing the dialog.
handle WM_SYSCOMMAND BUTTON
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
i got this as my class assignment. i am having hard time figuring this out im new to programming scene so please help...the instructions go as following:
The New Telephone Company has the following rate structure for long-distance calls:
The regular rate for a call is $0.20 per minute.
Any call started at or after 6:00 p.m. (1800 hours) but before 8:00 a.m. (800 hours) is discounted 50 percent for off-peak hours.
Any call longer than 60 minutes receives a 15 percent discount on it cost (after off-peak hours discount is subtracted)
All calls are subject to a 4 percent federal tax on their final cost.
Write a program that reads
The start time for a call based on a 24-hour clock
(Note: you only need start time and don’t need the end time)
The length of the call (number of minutes).
Your program needs to check for illegal inputs
Number of minutes cannot be 0 or negative
The start time for a call cannot be less than 0 or greater than 2359. Also the start time cannot be
1263, 885, 2099, etc… (WHY?)
If there is any error, print the appropriate error message and end the program by return -1.
(Note: you can put a return statement anywhere inside your program, when return statement is executed, the program will end.)
Finally, the program will print the following results:
The gross cost (before any discount or tax)
The net cost (after discounts are deducted)
The Final cost (with tax added).
Test your program with all scenarios. Illegal minutes, illegal starting time, regular call under an hour, regular call over an hour, off-peak call under an hour, off-peak call over an hour, 60 minute off-peak call,
60 minute peak time call………….etc………..
any help would be appreciated.
|
|
|
|
|
calizdesi wrote: The start time for a call cannot be less than 0 or greater than 2359. Also the start time cannot be
1263, 885, 2099, etc… (WHY?)
Those value limitations exist because they don't exist on a 24h clock. You should have noticed that 2359 is actually 23:59, that's why there cannot be any values larger then that. The other ones are 12:63, 8:85 and 22:99, and, has you know, each hour as 60 minutes, so it makes no sence talking about 63, 85 or 99 minutes.
I think you should write a function that converts an integer value (such as the ones provided by you) into its time equivalent. Given an input of 1263, the function could, for instance, return a structure containing those values separately.
struct sTime {
int Hours, Minutes;
};
And then check its values. Something like this:
struct sTime TimeLine;
int StartTime;
scanf( "%d", &StartTime );
TimeLine = IntToTime( StartTime );
So IntToTime would return a structure containg the values TimeLine.Hours == 12 and TimeLine.Minutes == 63. You may now validate them very easly:
if ( StartTime.Hours < 0 || StartTime.Hours > 23 || StartTime.Minutes < 0 || StartTime.Minutes > 59 )
If this statement is true, then you an invalid input.
As far as I can tell, the rest of the application is all about calculations, so I think this was your biggest stumbling problem (right?). Try it again.. If you can't let me know
regards [[]]
hint_54
|
|
|
|
|
first of all i would like to thank you for your help.i am very very very new to this so is there any way you can type the whole code or some important part of the code for me. ill be very grateful to you. thanks and regards.
-- modified at 18:52 Wednesday 15th March, 2006
|
|
|
|
|
hint_54
-- modified at 19:56 Wednesday 15th March, 2006
Have you already tried?
|
|
|
|