Height data of existing nodes getting updated when a new node is added

The code is trying to get the height of the existing nodes stored/updated as soon as a new node is added to the BST.

The algorithm is:

1: Insertion should take place in the BST fashion.

2: The height of the parent is updated by 1 only if the newly added node is is added to the sub_tree which is contributing to the height of parent (as height of node is max(height(left_sub_tree),height(right_sub_tree)) AND the height of the sub_tree has increased as well (making it equal to the height of its parent).

here is my code:

 #include<stdio.h>  #include<stdlib.h>   struct node  {      int data;      int height;      struct node *right;      struct node *left;  };   int indicator=0;  void left_insert(struct node*,struct node*);  void right_insert(struct node*,struct node*);   void left_insert(struct node *head, struct node *temp)  {      struct node *child=NULL;       if(head->data > temp->data)      {           if(head->left==NULL)          {              indicator=1;              child=head->left=temp;          }          else          {              left_insert(head->left,temp);              child=head->left;          }      }      else      {          right_insert(head,temp);      }       if((indicator==1)&&(child!=NULL))      {          if(head->height>child->height)          {              indicator=0;          }          else          {             head->height+=1;          }      }  }   void traverse(struct node *head)  {      if(head!=NULL)      {          traverse(head->left);          printf(" data   -> %d\n",head->data);          printf(" height -> %d\n\n",head->height);          traverse(head->right);      }  }   void right_insert(struct node *head, struct node *temp)  {      struct node *child=NULL;       if(head->data < temp->data)      {           if(head->right==NULL)          {              indicator=1;              child=head->right=temp;          }          else          {              right_insert(head->right,temp);              child=head->right;          }         }      else      {          left_insert(head,temp);      }       if((indicator==1)&&(child!=NULL))      {          if(head->height>child->height)          {              indicator=0;          }          else          {                head->height+=1;          }      }  }   int main()  {      struct node *head=NULL,*temp_head=NULL,*temp=NULL;      head=malloc(sizeof(*head));      head->data=8;      head->height=0;      head->right=head->left=NULL;      head->this=head;      temp_head=head;      indicator=0;      //HARDCODED DATA FOR INSERTION      temp=malloc(sizeof(*temp));      temp->data=3;      temp->height=0;      temp->right=temp->left=NULL;      left_insert(temp_head,temp);      temp_head=head;      indicator=0;       temp=malloc(sizeof(*temp));      temp->data=10;      temp->height=0;      temp->right=temp->left=NULL;      left_insert(temp_head,temp);      temp_head=head;      indicator=0;       temp=malloc(sizeof(*temp));      temp->data=1;      temp->height=0;      temp->right=temp->left=NULL;      left_insert(temp_head,temp);      temp_head=head;      indicator=0;       temp=malloc(sizeof(*temp));      temp->data=6;      temp->height=0;      temp->right=temp->left=NULL;      left_insert(temp_head,temp);      temp_head=head;      indicator=0;       temp=malloc(sizeof(*temp));      temp->data=14;      temp->height=0;      temp->right=temp->left=NULL;      left_insert(temp_head,temp);      temp_head=head;      indicator=0;       temp=malloc(sizeof(*temp));      temp->data=4;      temp->height=0;      temp->right=temp->left=NULL;      left_insert(temp_head,temp);      temp_head=head;      indicator=0;       temp=malloc(sizeof(*temp));      temp->data=7;      temp->height=0;      temp->right=temp->left=NULL;      left_insert(temp_head,temp);      temp_head=head;      indicator=0;       temp=malloc(sizeof(*temp));      temp->data=13;      temp->height=0;      temp->right=temp->left=NULL;      left_insert(temp_head,temp);      temp_head=head;      indicator=0;       traverse(temp_head);      return 0;  } 

The problem is I can’t come up with any edge cases to test it and I feel that I am completely at my wits end.

HSTS preload and requisites on domain – subdomains must be added too?

I found that the security header for protection against mitm attacks in first connection is to implement HSTS preload directive and add the list of google: https://hstspreload.org/

However the requisites to do that is to include all subdomains of the domain given. This makes a problem to websites that are really big, they just want to preload the domain and not the subdomains…

1)is there any way to make this work? 2) does the preload of the domain preloads subdomains too? i may be getting all wrong


personal example/experience:

i was doing pentesting against a website example.com and it was preloaded and added to the hstspreload list, however i found that vulnerable.example.com subdomain didn’t have HSTS header and it wasn’t preloaded, so of course it was vulnerable to mitm attacks, but how? it had the domain preloaded, and to add it there you need to add subdomains too… so was this an exeption or what happened here?

Problem with counting added files in dropzone js

I have this code:

<script type="text/javascript">             var fileLimit = {{ $  fileLimit }};              function refreshFileList() {                 $  (".dz-preview").remove();                 $  .ajax({                     url: '{{ route('showFilesDJS') }}?type={{ $  pageType }}&id={{ $  recordId }}',                     type: 'get',                     dataType: 'json',                     headers: {                         'X-CSRF-TOKEN': $  ('meta[name="_token"]').attr('content')                     },                     cache: false,                     success: function (response) {                         $  .each(response, function (key, value) {                             fileLimit = fileLimit - 1;                             var mockFile = {                                 name: value.name,                                 size: value.size                             };                             dpzMultipleFiles.emit('addedfile', mockFile);                             dpzMultipleFiles.emit('thumbnail', mockFile, value.path);                             dpzMultipleFiles.emit('complete', mockFile)                         })                     },                     error: function (response) {                         alert('Nastąpił problem z JSON. Proszę o kontakt z administratorem serwisu.');                     }                 });             }               Dropzone.options.dpzMultipleFiles =                 {                     maxFiles: fileLimit,                     clickable: true,                     thumbnailWidth: 250,                     thumbnailHeight: 250,                     autoProcessQueue: true,                     dictDefaultMessage: '',                     uploadMultiple: true,                     paramName: "myFile",                     acceptedFiles: ".jpg,.jpeg",                     addRemoveLinks: true,                     timeout: 50000,                     dictRemoveFile: 'Usuń plik',                      init: function () {                         dpzMultipleFiles = this;                         refreshFileList();                          this.on("thumbnail", function(file, dataUrl) {                             $  ('.dz-image').last().find('img').attr({width: '100%', height: '100%'});                         }),                          this.on('completemultiple', function (file, json) {                             //$  ('.sortable').sortable('enable');                              refreshFileList();                         });                         this.on('success', function (file, json) {                             //alert('aa');                         });                          this.on('addedfile', function (file) {                             alert('a');                             fileLimit = fileLimit - 1;                         });                          this.on('drop', function (file) {                             console.log('File', file);                             alert('b');                             fileLimit = fileLimit + 1;                         });                          this.on("maxfilesexceeded", function (file) {                             alert('Plik ' + file.name + ' nie został wysłany na serwer. Limit plików został przekroczony!')                             this.removeFile(file);                         });                     },                       removedfile: function (file) {                         console.log(file.name);                         $  .ajax({                             headers: {                                 'X-CSRF-TOKEN': $  ('meta[name="_token"]').attr('content')                             },                             cache: false,                             type: 'POST',                             url: '{{ route('deleteDJS') }}?id='+file.name+'type={{ $  pageType }}',                             data: {filename: file.name, id: file.name, type: '{{ $  pageType }}'},                             success: function (data) {                                 console.log("File has been successfully removed!!");                                 //refreshFileList();                             },                             error: function (e) {                                 console.log(e);                             }                         });                          var fileRef;                         return (fileRef = file.previewElement) != null ?                             fileRef.parentNode.removeChild(file.previewElement) : void 0;                     }                 };         </script> 

In {{ $ fileLimit }} – I have limit files set to 4.

Is the above code correct? I can add more than 4 files via dropzone 🙁 How to fix this?

I would like that it would not be possible to add more than 4 files.

After adding the last file, I would like to refresh the list of files for the refreshFileList function

How do you get current date to be added to a cell when a check box is checked in another cell

I want to get the current date added into a cell when a tick box is checked in another cell.

I currently have another formula in the date cell which changes its colour when the tick box is checked, but I also want the date automatically added at the same time as it changing colour.

The colour change is working using this formula, =COUNTIF(F12,”=Y”) I want the cell to automatically add the date too. Can anyone help with the additional formula and how do I combine them both?

Added nouveau.modeset=0 now black screen and nothing

Running Ubuntu 18.04.2. My system is crypt.

I was having an issue where Ubuntu didn’t seem to be waking up after screen idle timeout and lock. I would have to hard crash the system and then reboot.

Followed suggestion on this post to enter nouveau.modeset=0 to grub. After doing that and sudo update-grub and a reboot, now I never see the bios setup options, never see the enter crypt password. Can’t CTRL+ALT+F1, F6, or F7. Totally screwed my system. I can’t ssh in either.

Don’t enter nouveau.modeset=0!

So now what? How do I get back into my system? I’ve tried without being able to see anything at all to enter my crypt password. Then going through the motions of trying to login blind and possibly set my grub back, but it is not working. Just blank! It drives me nuts that this is an issue in this day and age. Should just work.

intermidiate certificate not in keystore even though i added it

I was tasked to set up an ssl in a server, this server uses wildfly, so i have to make a keystore that contains all of the certificates that i got, the server certificate, the intermidiate and the keyfile, first i chained up the server cert and the intermidiate cert, and then i used openssl to create a pkc12 file and then i used keytool to create a keystore from that pkc12 file, the problem is when i open the keystore file or the pkc12 file, it find that it doesn’t contain the intermidiate cert, it only has the server cert, which is weird, because i’ve done this procedure before and it worked, any one knows what can the problem be ? Extra info : the intermidiate certificate is a little old (from 2010) and uses sha1 and will expire in 9 months which is weird, unlike my server cert which is new and uses sha256.

Please help, Thank you,