Will try to do the same.
Type: Posts; User: Debojyoti Das
Will try to do the same.
Sorry for being late, here's the solution that I did, don't know how efficient it is...
#include <stdio.h>#include <stdlib.h>
size_t read_numbers(int numbers[], int max_size)
{
size_t i...
Sorry for my so less experience in coding, but I have never seen a while loop number reading like this. Can you please explain the logic so that I can implement loops like this myself? The...
#include <stdio.h>#include <stdlib.h>
#define MAXVALUE 10
int compact (int[], int);
int main()
{
int arrSeries[MAXVALUE], i=0, newArrayLength;
int arrLength = MAXVALUE;
printf("Please enter...
Whoa..now I recognize it. Thanks for the take :) .
Just to do replace the garbage values I guess. And in my version of the code I get the reduced range based on my lastVal thingy. I do recognize that other workarounds are possible and I will try...
It surely does :) ! Thanks :) .
Not exactly divide and conquer but my approach will be to divide the partition into repeating sets and then put one instance for the same and keep the non-repeating sets as is. I think it might be...
Out of bounds :(. Silly me.
Edited. Returns correct results for me :). Added a newline character as well :) .
#include <stdio.h>#include <stdlib.h>
#define MAXVALUE 10
int compact (int[], int);
int main()
{
int...
Wow ! I will change and try to fix the bug :) .
EDIT: You missed a semicolon there :) .
An in-place solution would surely reduce space complexity and as this would be a divide and conquer method, time complexity may improve. A good proposition indeed.Working out now :) .
Here's the final code:
#include <stdio.h>
#include <stdlib.h>
#define MAXVALUE 10
int compact (int[], int);
int main()
{
True the actual question doesn't want me to print the compact array but just for my programming practice I took on the (ARGH! :)) task :D. Thanks for the heads up on C++, I am yet to learn that :( ....
Well a new train of thought came to me. Why not I just remember the last digit in the array of number the user inputs, fill the array say (last digit+1) and during result output truncate all digits...
That's a great idea ! Atleast the user won't need to see zeroes and garbage values :) . Thanks.
Thanks :) . Maybe I will prompt user not to enter 0's :D .
Yes j has the same value, thank you for making me notice :) . Changed the code and also added data acceptance from user:
#include <stdio.h>#include <stdlib.h>
#define MAXVALUE 10
void...
#include <stdio.h>#include <stdlib.h>
void compact (int[], int);
int main()
{
int arrSeries[11] = {1, 1, 1, 2, 2, 1, 2, 3, 3, 1, 1 };
int arrLength = 11;
compact(arrSeries,...
It got deleted for reasons I don't know :(
Well it's the number of steps my first and second piece of code does for similar set of numbers. In fact the second piece of code was provided a...
while(l<MAXSIZE) {
i=0, j=0;
while(i < MAXSIZE)
{
if(changeArray[i]==changeArray[i+1])
{
j=i;
while(j < MAXSIZE)
{
changeArray[j]=changeArray[j+1];
Why did they keep v and b adjacently on the keyboard ;) ??
You are recommending me to find out it's time complexity. Sure thing doing it now :) .
Here's my solution (it work's :) ) but it became quite complex and due to the shifting the garbage value also shows.
Now will think on R.Stiltskin's idea.
#include <stdio.h>#include <stdlib.h>...
Thanks ! Working on it !