## Difficulty understanding Algorithm to print Partitions of a Number [on hold]

Here’s a code I came across, which aims to print the partitions of a given number $$n$$

I am unable to understand how the code accomplishes what it does, i.e. I’ve difficulty in understanding the algorithm. How does the code work?

``#include <stdio.h> #include <string.h> #include <math.h> // Take a number and print it textually // For non-positive numbers it returns the empty string void itoa(int n, char *str){ if(n <= 0){     str[0] = '';     return; } int i, len = floor(log10(n) + 1); // number of digits in n for(i = len - 1; i >= 0; i--){     str[i] = '0' + (n % 10);     n /= 10; } str[len] = ''; }  // n tell us which number is to be partitioned // next tells us the location in the string where to print next // min tell us the minimum number we must choose next void partition(char *str, int n, int next, int min){ if(n == 0){     str[next] = '';     printf("%s\n", str);     return; } int i; // If this is not the first number in the partition // we need a plus sign before we print the next number if(next)     str[next++] = '+'; // Start from min so that numbers in a partition are always // in a non-decreasing order. This ensures that we will never // repeat a partition twice for(i = min; i <= n; i++){     itoa(i, str + next);     // We have already absorbed i so now partitions of n-i needed     // All future numbers in this partition must be at least i     partition(str, n - i, next + strlen(str + next), i); } }  int main(){ char str[1000]; // This code will output partitions in lexicographically increasing // order. However, lexicographic order means something a bit different // for this code. Nevertheless, no partition will be repeated twice. int n; scanf("%d",&n); // This code can handle any positive number, with any number of digits,  // so long as writing the parition does not take more than 999 chars partition(str,n, 0, 1); return 0; } ``

Any and all help will be appreciated. Thank you!

## Install alongside win7 what partitions do I need to set?

I’ve got a 40gb unallocated partition on my c: drive. Might be a bit much but it’s ok.
I’m looking to install Ubuntu 19 I’ve seen on some guides that I need to define swap and root stuffs. I’m a linux baby so I really don’t know whats actually needed.
16gb Ram, not worried about hibernate if that matters.

## Are the partitions totally separate when using dual boot?

I currently have a PC with Windows 10 and a 1 TB SSD. I’m planning on partitioning the disk and installing Ubuntu on the other partition, so that I can have dual boot. My question is; are the partitions totally separate? Meaning that if I’m running my PC with Windows on partition A, do I have access to the files stored on partition B where Ubuntu is installed? And likewise, say I create a .java file for work while working on Ubuntu on partition B, can I store this file on partition A and have access to this no matter which OS I’m currently on?

Will it matter where my files (not OS) are stored, so I should consider this when choosing the size of my partitions?

## Installing Ubuntu: cannot disable fast boot and no partitions showing

I’m trying to install Ubuntu 18.04 (dual boot / alongside Windows) on my Lenovo Yoga 520 with the InsydeH20 BIOS Setup Utility, but I have the following problems:

1. I cannot disable fast boot. I know that disabling the option is needed for a correct installation, but disabling it in the boot menu has no effect. Turning off the computer and checking the boot menu again yields seeing the “Fast boot” option as active (the BIOS battery should not be dead as other options survive)

2. The installer sees no partitions. When trying to install the OS, the installer doesn’t show me any partitions to select.

I managed to fix one problem though: I used to get the error “MODSIGN: Couldn’t get UEFI db list” but managed to “fix” it by resetting some keys in the boot menu (now I only get the error “Couldn’t get size: 0x000…”).

I have already disabled fast startup in Windows but it doesn’t seem to have any effect as can be seen here… My only idea for the cause would a broken hybernation file.

## If I delete all partitions during Ubuntu installation and create efi partition, will I need to update firmware?

I am installing Ubuntu 19.04 on laptop(it has SSD drive) that comes with Free DOS predinstalled. I set BIOS to boot as uefi and I will delete all current partitions and create efi (with boot flag), root and home. Will everything be OK or, I will need to update firmware. Thank you in advance.

## Parted saying “cant have overlapping partitions” but no partitions overlap

Image of issue

Hello all, I am having an issue with my raspberry pi. I am trying to move it from one sd card to another larger one,and when I resizepart it says there is an overlapping partition, but I do not see one. Is there something i am missing?

Log:

``(parted) print free Model: Generic STORAGE DEVICE (scsi) Disk /dev/sda: 128GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags:  Number  Start   End     Size    Type      File system  Flags         32.3kB  4194kB  4162kB            Free Space  1      4194kB  1936MB  1932MB  primary   fat32        lba  2      1936MB  15.9GB  14.0GB  extended  5      1938MB  1971MB  33.6MB  logical   ext4  6      1971MB  2044MB  72.4MB  logical   fat32        lba  7      2047MB  15.0GB  13.0GB  logical   ext4         15.0GB  15.9GB  932MB             Free Space         15.9GB  128GB   112GB             Free Space  (parted) resizepart 7 End?  [15.0GB]? 100.0GB Error: Can't have overlapping partitions. (parted) ``

## Removing Old Partitions

I’m trying to wipe data from an old drive but no matter what I do, the partitions seem to remain. When applying the changes after removing the partitions, gParted gives errors, then shows the full unallocated area but afterward when it finishes its scan, the partitions have returned. How can I get rid of them? The drive itself is being accessed using a USB “toaster” that I always use when managing separate drives.

## How can I protect my linux partitions against corruption by Ext2Read?

I have 2 disks. The first one contains my ubuntu main OS, along with another partition where GRUB is located.

Another disk has a windows 10 installed with an utility, Ext2Read, installed as a service to read ext partitions (i.e. the ubuntu one)

Each time I boot on windows, the ext2read service mount my ubuntu partition and thus corrupt it. When I reboot on Ubuntu, I have superblock issues, and have to repair the disk.

Last time, I couldn’t fix it without using a live CD and several tools to repair everything, not to mention that I am no expert on the matter and often might not make the best repair choices.

I need that windows OS for CAD purposes, and my original idea was to unplug the Ubuntu disk before booting, but then I do not have grub and nothing to boot on.

What could I do to fix this, ideally without reinstalling a fresh windows? Can I somehow either protect the linux partitions, or boot without grub on windows, in order to remove that Ext2Read software & service?

Feel free to request any additional info on my system.

Thanks!

## Rearranging disk partitions

I’m trying to set up a dual boot system on an HP Pavilion laptop. I can’t get it to boot into Ubuntu directly on power-up, and I think the reason is that the Windows partition comes before the Ubuntu partition. This behavior seems to be coming from the underlying HP software, since pressing F9 on bootup gives me a menu where I can select which system to boot. That menu, however, does not offer any way to change the sequence of its entries.

I think I can solve the problem by reordering the partitions using gparted from a live system on a memory stick, but I don’t know if it’s sufficient to just change the numbers (doable with fdisk) or if the partitions actually have to be moved within the physical disk. The danger, of course, is that any change of this nature can render the system unbootable. Is there a way to do this safely?

## Ubuntu and Windows Partitions Appearing Under the Same Name

I’m trying to install Ubuntu on my SSD along Windows 10. I started by installing Windows 10, disabling fast boot and then trying to install Ubuntu. I created a Swap of 16gb. Ubuntu told me I needed an EFI so I created one of about 100 mb. The root took the remaining space. However when I restarted my computer I don’t see any partitions, and simply see this: (https://i.imgur.com/6RTFWBB.jpg). If I click the hard drive it’ll just say no os found.

I went back to check the partitions through the Ubuntu installer and see this: https://i.imgur.com/3ZcVeLN.jpg

It looks like the partitions were installed correctly, but I’m not getting a proper boot loader to choose between windows and Ubuntu. What should I do?